About the acquisition of url Chinese parameters

       There are many methods for obtaining url parameters with regular expressions on the Internet, but generally this method cannot transcode Chinese parameters. Here is a method for obtaining url Chinese parameters.

function getRequest() {
var url = window.location.search; //获取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]]=decodeURI(strs[i].split("=")[1]); 
 
}
}
return theRequest;
}

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326418148&siteId=291194637