js获取url地址
在實(shí)際開發(fā)中,需要用js獲取當(dāng)前url的地址,可以直接用 windows.location.href
或者需要獲取url中具體的某一個參數(shù):
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中參數(shù)名傳進(jìn)去,就可以返回參數(shù)值了。
創(chuàng)作挑戰(zhàn)賽新人創(chuàng)作獎勵來咯,堅持創(chuàng)作打卡瓜分現(xiàn)金大獎總結(jié)
- 上一篇: 今起可提前预约个税办税:每天6-22点可
- 下一篇: laravel中的数据迁移表结构、字段类