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.
<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>
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.