/** * 根据url查询字符串里的键名获取其值 */ function getSearchString(key, search) { // 获取URL中?之后的字符 var str = search; str = str.substring(1,str.length); // 以&分隔字符串,获得类似name=xiaoli这样的元素数组 var arr = str.split("&"); var obj = new Object(); // 将每一个数组元素以=分隔并赋给obj对象 for(var i = 0; i < arr.length; i++) { var tmp_arr = arr[i].split("="); obj[decodeURIComponent(tmp_arr[0])] = decodeURIComponent(tmp_arr[1]); } return obj[key]; }
/** * 根据参数名,获取url后面的参数的值 * */ function getQueryVariable(variable) { var query = window.location.search.substring(1); var vars = query.split("&"); for (var i=0;i
ecodeURI()方法编码;如下:
window.location.replace (encodeURI("task_list.html?serial="+$("#serial").val()+"&start_time="+$("#start_time").val()));
\\\\\\\\\\\\\\\\\\\\\\\
//URL获取 function GetUrlParms() { var args=new Object(); var query=location.search.substring(1);//获取查询串 var pairs=query.split("&");//在逗号处断开 for(var i=0;i