js通过location.search来获取页面传来的参数
2014-09-11 16:52
1056 查看
这篇文章主要介绍了通过window.location.search来获取页面传来的参数,经测试是OK的
function GetQueryString(name) { var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)","i"); var r = window.location.search.substr(1).match(reg); if (r!=null) return (r[2]); return null; }
var sname = GetQueryString("name"); if(sname!=null) { var sname_ = decodeURIComponent(sname); alert(sname_); }
测试
abcd.html?name=xyz
应该弹出xyz
您可能感兴趣的文章:
相关文章推荐
- js通过location.search来获取页面传来的参数
- js通过location.search来获取页面传来的参数
- js通过location.search来获取页面传来的参数
- 通过window.location.search获取页面url传递的参数
- JS控制静态页面之间传递参数获取参数并应用(window.location)
- JS控制静态页面之间传递参数获取参数并应用(window.location)
- JS中利用location.search在客户端获取URL参数
- JS获取页面通过URL传的参数
- js通过获取地址栏参数跳转页面
- js通过获取地址栏参数跳转页面
- 后端往前段传递参数,大部分人都清楚,无非就是发起ajax请求获取后端值,然后通过js写入html相应位置即可。但是前段html页面之间,怎么传递参数呢?
- js:通过正则匹配获取页面的url中的参数
- javascript获取超链接传递的参数,此方法亦能解决2个通过js超链页面传递参数的乱码问题
- 巧用正则和document.location.search获取URL参数的值
- 通过js从父页面获取子页面的值(转)
- js获取上一个页面传来的URL参数
- Node.js通过jquery的ajax来获取参数
- js获取页面传递参数(完整版)
- 最近接触到的一些js调用window窗体的属性及通过JavaScript获取页面大小
- js获取当前Url网址路径及参数 location.hostname