1. 程式人生 > >js獲取請求地址引數

js獲取請求地址引數

var url = location.search;
//獲取url"?"符後的字串
var url =  encodeURI(url);//對url中文進行轉碼
var theRequest = new Object();
if (url.indexOf("?") != -1) {
    var str = url.substr(1);
    strs = str.split("&");
    for(var i = 0; i < strs.length; i ++) {
        theRequest[strs[i].split("=")[0]]=unescape(strs
[i].split("=")[1]); } }
var url=theRequest.id;