varUrltools = { //get Rul parameter valueGeturlparam:function(name) {/*? videoid=identification*/ varparams = decodeURI (Window.location.search);/*intercept? After the part index.html?act=doctor, the truncated string is? Act=doctor*/ varReg =NewRegExp ("(^|&)" + name + "= ([^&]*) (&|$)"); varr = Params.substr (1). Match (REG); if(r!=NULL)returnUnescape (r[2]);return NULL; }};
var categoryId = Urltools.geturlparam ("CategoryId"); Get the parameters in the URL
The second Kind
the following JS function is used to get the URL parameters:functiongetqueryvariable (variable) {varquery = window.location.search.substring (1); varVARs = Query.split ("&"); for(vari=0;i<vars.length;i++) { varPair = Vars[i].split ("="); if(Pair[0] = = variable) {returnPair[1];} } return(false);} Use instance URL instance: http://www.runoob.com/index.html?id=1&image=awesome.jpgCall getqueryvariable ("id") to return 1. Call Getqueryvariable ("Image") returns "Awesome.jpg".
JavaScript gets the parameters in the URL