html跳转到html页面,url后面携带参数,可以通过脚本获取到url?test=value地址后的参数。
1、more.html 携带参数跳转到list.html,get提交参数
2、list.html 获取more.html提交过来参数
1、more.html:
- <script>
- function test() {
- window.location.href = "list.html?test=value";
- }
- </script>
2、list.html:
- <script type="text/javscript">
- function GetRequest() {
- var url = location.search; //获取url中"?"符后的字串
- var theRequest = new Object();
- if (url.indexOf("?") != -1) {
- var str = url.substr(1);
- strs = str.split("&");
- for (var i = 0; i < strs.length; i++) {
- theRequest[strs[i].split("=")[0]] = unescape(strs[i].split("=")[1]);
- }
- }
- return theRequest;
- }
- $(document).ready(function () {
- var Request = new Object();
- Request = GetRequest();
- var val= Request["test"];
- alert(val);
- });
- </script>