这篇文章主要介绍了通过window.location.search来获取页面传来的参数,经测试是OK的 ? 1 2 3 4 5 function GetQueryString(name) { var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)","i"); var r = window.location.search.substr(1).match(reg); if (
获取页面传来的参数 <div> <script> function GetQueryString(name) { var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i"); var r = window.location.search.substr(1).match(reg); if (r != null) return (r[2]);
转载的,先记下: UrlParm = function () { // url参数 var data, index; (function init() { data = []; index = {}; var u = window.location.search.substr(1); if (u != '') { var parms = decodeURIComponent(u).split('&'); for (var i = 0, len = parms.length; i < len;
举个例子说一下: http://wwww.yctech.com/blog/post?id=1 像这样的话,通常通过如下代码直接截取不用做任何处理: function getQueryString(name) { var result = window.location.search.match(new RegExp("[\?\&]" + name + "=([^\&]+)", "i")); ) { return "&qu