function getRequest(url) {
url = url ? url : window.location.search
let theRequest = new Object()
if (url.indexOf('?') != -1) {
//url中存在问号,也就说有参数。
let str = url.split('?')[1]
let strs = str.split('&')
for (let i = 0; i < strs.length; i++) {
theRequest[strs[i].split('=')[0]] = decodeURI(strs[i].split('=')[1])
}
}
return theRequest
}
let query = getRequest()
JavaScript【获取地址栏参数】
最新推荐文章于 2024-11-11 11:20:06 发布