function getQueryString(key) { var reg = new RegExp("(^|&)" + key + "=([^&]*)(&|$)"); //如果地址栏中出现中文则进行编码 var r = encodeURI(window.location.search).substr(1).match(reg); if (r != null) { //将中文编码的字符重新变成中文 return decodeURI(unescape(r[2])); } return null; } if (location.href.indexOf('index.html?srcType') > -1) { localStorage.setItem('srcType', getQueryString('srcType')) // location.href="http://hbmemhg.cn/file-smallv_/0qlm/web_qianlimaDataMall/index.html" location.href="http://hbmemhg.cn/file-smallv_/0qlm/wxh5_testDemand/wj200316/index.html" }