获取url地址参数

https://expert.baidu.com/zhuanjia/questionpc#/med/ask-doctor 

 

 function getQueryString(name) {
                var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)');
                var search = window.location.href.split('?')[1];
                if (search) {
                    var r = search.match(reg);
                    if (r !== null) {
                        return decodeURIComponent(r[2]);
                    }
                }
                return '';
            }

 

你可能感兴趣的:(获取url地址参数)