Use PHP, ASP, and asp.net to obtain the gonten.com/s.php? The parameter id = 123 & name = gonten is simple, but Javascript does not directly obtain the function. You must use a custom function. There are also many methods on the Internet, but some code is a little bloated.
Gonten writes a simple piece of code, which can be well obtained. The principle is to obtain the whole URL address and then perform cutting and other processing.
The Code is as follows:
<Script type = "text/javascript">
Function gt (gonten ){
Var url = window. location. href;
Var u = url. split ("?");
Var s, ss, str;
If (u. length = 1) s = ";
Else s = u [1];
Ss = s. split ("&");
Gonten = gonten. toLowerCase ();
Str = gonten + "= ";
Var j = ss. length;
For (I = 0; I <j; I ++ ){
If (ss [I]. indexOf (str) = 0 ){
Ss [I] = ss [I]. toLowerCase ();
$ Gonten_str = ss [I]. replace (str ,"");
Break;
}
}
Return $ gonten_str;
}
</Script>
Usage:
<Script type = "text/javascript">
Var IP = gt ("ip"); // get
Document. write (IP); // output
</Script>
This article is from: www.Gonten.com