Javascript|request
To do the conversion of the Chinese and English, to get the exact parameters and take out, so do a simple HTML in the use of JS to get the address bar of an object.
There are three ways:
1, request. QueryString ("Parameters")//Gets the specified parameter, returns a string;
2, request. Querystrings ()//Get all the parameters and return the array;
3, Request.setquery ("parameter", "value of the parameter");//If this argument is present in the current address bar, this parameter is updated, otherwise a new Address bar argument string is returned.
For example:
The current address bar parameter string is:? name=a&site=never_online
Alert (request.setquery ("name", "Bluedestiny"))
If "name" is in the Address bar argument, then return? name=bluedestiny&site=never_online
The Setquery method has the function of automatically appending parameters. Such as:
The current address bar parameter string is:? site=never_online
Alert (request.setquery ("name", "Bluedestiny"))
Then return? site=never_online&name=bluedestiny
Similarly, if the address bar has no parameters, the parameters are automatically appended
Alert (request.setquery ("name", "Bluedestiny"))
Back? name=bluedestiny
<script language= "JavaScript" >
<!--
Author:never-online
Web:never-online.net
var request = {
Querystring:function (val) {
var uri = Window.location.search;
var re = new RegExp ("+val+" \=) ([^\&\?] *) "," IG ");
Return (Uri.match (re))? ( Uri.match (re) [0].substr (val.length+1)): null);
},
Querystrings:function () {
var uri = Window.location.search;
var re =/\w*\= ([^\&\?] *)/ig;
var retval=[];
while ((arr = re.exec (URI))!= null)
Retval.push (Arr[0]);
return retval;
},
Setquery:function (Val1, Val2) {
var a = this. Querystrings ();
var retval = "";
var seted = false;
var re = new RegExp ("^" +val1+ "\=") ([^\&\?] *) $ "," IG ");
for (var i=0; i<a.length; i++) {
if (Re.test (A[i])) {
Seted = true;
A[i] = val1 + "=" + val2;
}
}
retval = A.join ("&");
Return "?" +retval+ (seted?) "": (retval?) & ":") +val1+ "=" +val2);
}
}
Alert (Request.setquery ("E", "B"))
-->
</SCRIPT>