This article has a collection of four JS access to the address bar parameter instance functions, they will use the splite to take? The parameters behind, and then split to separate & back parameters Oh, save to the data and then processed OH.
<script language= "Web Effects" >
var Url=window.location.search;
if (url.indexof)! =-1)
{
var str = URL.SUBSTR (1)
STRs = Str.split ("&");
for (i=0;i<strs.length;i++)
{
document.write ([Strs[i].split ("=") [0]], ' = ', unescape (strs[i].split ("=") [1]), ' <br> ';
}
}else document.write (' no parameters ');
</script>
Method Two
<script type= "Text/javascript" >
<!--
function request (strname) {
var strhref = "www.jzread.com/index.html?id=1&c=2";
var intpos = Strhref.indexof ("?");
var strright = strhref.substr (intpos +);
var arrtmp = Strright.split ("&");
for (var i = 0; i < arrtmp.length i) {
var arrtemp = arrtmp[i].split ("=");
if (arrtemp[0].touppercase () = = Strname.touppercase ()) return arrtemp[];
}
Return "";
}
Alert (Request ("a"));
Alert (Request ("B"));
Alert (Request ("C"));
-->
</script>
Method Three
<script language= "JavaScript" >
var id= ';
var Url=window.location.search;
if (url.indexof)! =-1)
{
var str = URL.SUBSTR (1)
STRs = Str.split ("&");
for (i=0;i<strs.length;i++)
{
if ([Strs[i].split ("=") [0]]== ' id ') id=unescape (strs[i].split ("=") [1]);
}
}
</script>
Method Four
<script type= "Text/javascript" >
function Urlsearch ()
{
var Name,value;
var str=location.href; Get the entire address bar
var num=str.indexof ("?")
Str=str.substr (num+1); Get all parameters
var arr=str.split ("&"); Each parameter is placed in an array
for (Var i=0;i < arr.length;i++) {
Num=arr[i].indexof ("=");
if (num>0) {
Name=arr[i].substring (0,num);
Value=arr[i].substr (num+1);
This[name]=value;
}
}
}
var request=new urlsearch (); Instantiated
alert (request.id);
</script>
For example, save this code as 1.html.
So I'm going to visit 1.html?id=test.
This is the time to get the test value.
Call in HTML
<script type= "Text/javascript" >
var a= "http://jzread.com";
</script>
</head>
<body>
<a id= "A1" href= "" >sadfsdfas</a>
<script>
var A1=document.getelementbyid ("A1");
A1.href=a;
</script>
<script type= "Text/javascript" >
var a= "HTTP://WWW.AIMEIGE.COM.CN?CCTV";
var s=a.indexof ("?");
var t=a.substring (s+1);/T is what's behind it. </script>