JS 获取地址栏值

版权声明:大柱子 https://blog.csdn.net/weixin_43044132/article/details/88295803

function getUrlParam(name) {
var reg = new RegExp("(^|&)" + name + “=([^&]*)(&|$)”); //构造一个含有目标参数的正则表达式对象
var r = window.location.search.substr(1).match(reg); //匹配目标参数
if (r != null) return unescape(r[2]); return null; //返回参数值
}

url = window.location.href;

        did = url.substring(url.length, url.lastIndexOf('=') + 1);

猜你喜欢

转载自blog.csdn.net/weixin_43044132/article/details/88295803