Here is a JavaScript client solution that gets the URL with the questring parameter, equivalent to the ASP's request.querystring,php $_get
Function:
function Getrequest () {
var url = location.search; Gets the URL in the "?" String after the character
var therequest = new Object ();
if (Url.indexof ("?")! =-1) {
var str = URL.SUBSTR (1);
STRs = Str.split ("&");
for (var i = 0; i < strs.length; i + +) {
Therequest[strs[i].split ("=") [0]]= (Strs[i].split ("=") [1]);
}
}
return therequest;
}
Then we get the corresponding parameter value by calling this function:
var Request = new Object ();
Request = Getrequest ();
var parameter 1, Parameter 2, parameter 3, parameter n;
Parameter 1 = request[' parameter 1 '];
Parameter 2 = request[' parameter 2 '];
Parameter 3 = request[' parameter 3 '];
Parameter n = request[' parameter n '];
This gets the parameter with the same name in the URL string
Second, the regular analysis method.
function getquerystring (name) {
var reg = new RegExp ("(^|&)" + name + "= ([^&]*) (&|$)", "I");
var r = window.location.search.substr (1). Match (REG);
if (r!=null) return (r[2]); return null;
}
Alert (getquerystring ("parameter name 1"));
Alert (getquerystring ("parameter Name 2"));
Alert (getquerystring ("parameter name 3"));
This article is from the "Liu Bofang blog" blog, make sure to keep this source http://liubofang.blog.51cto.com/11162557/1858565
Get the Get parameter method with JS on HTML page