function getQueryString(key){
var reg = new RegExp("(^|&)"+key+"=([^&]*)(&|$)");
var result = window.location.search.substr(1).match(reg);
return result?decodeURIComponent(result[2]):null;
}
var pstr = encodeURIComponent(JSON.stringify(PARAMS));
var URI = getQueryString('params');
if(URI.indexOf('%') > -1) {
URI = URI.replace(/%/g,'%25')
}
1. encodeURI() 和 decodeURI()
2. encodeURIComponent() 和 decodeURIComponent()
var str = "http://www.baidu.com?params=张三";
console.log(encodeURI(str));
var strDecode = encodeURI(str);
console.log(decodeURI(strDecode));
console.log(encodeURIComponent(str));
var strdecodeURI = encodeURIComponent(str);
console.log(decodeURIComponent(strdecodeURI));