封装GetQueryString()方法来获取URL的value值

扫二维码进入页面,截取url“?”后面的value,url为.../monitorScreen/category.html?ridgeCode=ZT1S010005

function getQueryString(name) {
                var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
                var url = window.location.search;
                var r = url.substr(1).match(reg);
                if(r != null) return unescape(r[2]);
                return null;
            }
var code = getQueryString('ridgeCode');

打印code则为ZT1S010005

posted @ 2019-08-21 17:58  额爷  阅读(335)  评论(0编辑  收藏  举报