Two native methods of obtaining parameters via URLs (typically provided using a framework):
Method One (recommended):
Urlinfo=window.location.href; Gets the URL of the current page
len=urlinfo.length;//gets the length of the URL
Offset=urlinfo.indexof ("?"); /Set the start position of the parameter string
NEWSIDINFO=URLINFO.SUBSTR (Offset,len)//Take out the parameter string and get a string like "id=1"
Newsids=newsidinfo.split ("=");//The obtained parameter string is split by "="
newsid=newsids[1];//Get parameter values
Method Two:
function Getquerystringargs () {
Get the query string and remove the question mark from the beginning
var qs = (location.search.length > 0? location.search.substring (1): ""),
args = (),
Items = qs.length? Qs.spilt ("&"): [],
Items = NULL,
name = NULL,
Value = NULL,
i = 0,
len = items.length;
For (I=0;i < Len; i++) {
Item = item[i].split ("=");
Name = decodeURIComponent (item[0]);
Value = decodeURIComponent (item[1]);
if (name.length) {
Args[name] = value;
}
}
return args;
}
Two ways to get URL parameters for native javascript