js获得url请求参数
直接上代码不费话了。
A页代码:
<a href="Default.aspx?id=http://www.cnblogs.com/leeyongze">打开</a>
Default.aspx为接收页(B页),
B页代码:
1 <script type="text/javascript">
2 window.onload = newhttp;
3 function Parameter() {
4 var Request = new function () {
5 this.search = window.location.search;
6
7 this.QueryString = new Array();
8
9 var tmparray = this.search.substr(1, this.search.length).split("&")
10 for (var i = 0; i < tmparray.length; i++) {
11 var tmpStr2 = tmparray[i].split("=");
12 this.QueryString[tmpStr2[0]] = tmpStr2[1];
13 }
14 }
15 var id = Request.QueryString["id"];
16 alert(id);
17 }
18 </script>
2 window.onload = newhttp;
3 function Parameter() {
4 var Request = new function () {
5 this.search = window.location.search;
6
7 this.QueryString = new Array();
8
9 var tmparray = this.search.substr(1, this.search.length).split("&")
10 for (var i = 0; i < tmparray.length; i++) {
11 var tmpStr2 = tmparray[i].split("=");
12 this.QueryString[tmpStr2[0]] = tmpStr2[1];
13 }
14 }
15 var id = Request.QueryString["id"];
16 alert(id);
17 }
18 </script>
作者:Mr S.R Lee
出处:http://www.cnblogs.com/LeeYongze
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利.