The previous get URL address parameter used by colleagues today is not available. The previous method failed. A regular expression bug was found later:
The first method of acquisition (generally sufficient for general conditions):
function getquerystring (name) {var reg = new RegExp ("(^|&)" + name + "= ([^&]*) (&|$)", "I"); var reg_rewrite = new RegExp ("(^|/)" + name + "/([^/]*) (/|$)", "I"); var r = window.location.search.substr (1). Match (REG); var q = window.location.pathname.substr (1). Match (Reg_rewrite); if (r! = null) {return unescape (r[2]); }else if (q! = null) {return unescape (q[2]); }else{return null; }}
The second method of getting:
The URL address is not getting: file:///Users/wanghong/work/ziku/youle/dist/index.html?sourceType=Tsingtao_beer _activity#/welcome?topath=file%3a%2f%2f%2fusers%2fwanghong%2fwork%2fziku%2fyoule%2fdist%2findex.html% 3FSOURCETYPE%3DTSINGTAO_BEER_ACTIVITY%23%2F
/** * Gets the specified URL parameter value * url:http://www.quwan.com/index?name=tyler * parameter: paramname URL parameter * Call method: GetParam ("name") * return value: Tyler */f Unction 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}
Let's have a try. Happy Lantern Festival
Get the Address bar URL in the parameters, Getquerysting () method