JS_0010:获取url中指定的参数

时间:2020-07-03 16:17:13   收藏:0   阅读:66

1,获取url中指定的参数

//获取url中指定参数
function getParam(name) {
    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
    var URL = decodeURI(window.location.search);
    var r = URL.substr(1).match(reg);
    if (r != null) {
        //decodeURI() 函数可对 encodeURI() 函数编码过的 URI 进行解码
        return decodeURI(r[2]);
    };
    return null;
}
console.log(getParam(‘aaa‘));

 

技术分享图片

 

原文:https://www.cnblogs.com/eliteboy/p/13230641.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!