js获取url地址
在實際開發中,需要用js獲取當前url的地址,可以直接用 windows.location.href
或者需要獲取url中具體的某一個參數:
function getParam(paramName) { paramValue = '', isFound = !1; if (this.location.search.indexOf('?') == 0 && this.location.search.indexOf('=') > 1) { arrSource = unescape(this.location.search).substring(1,this.location.search.length).split('&'), i = 0; while (i < arrSource.length && !isFound) arrSource[i].indexOf('=') > 0 && arrSource[i].split('=')[0].toLowerCase() == paramName.toLowerCase() && (paramValue = arrSource[i].split('=')[1], isFound = !0), i++ } return paramValue == '' && (paramValue = null), paramValue }將你url中參數名傳進去,就可以返回參數值了。
創作挑戰賽新人創作獎勵來咯,堅持創作打卡瓜分現金大獎總結
- 上一篇: 今起可提前预约个税办税:每天6-22点可
- 下一篇: AI 搜索之战被指反应迟缓,谷歌 CEO