匹配URL參數的正則表達式是: var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i"); ...
匹配URL參數的正則是:
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
JS代碼:
var getQueryString = function (name) { var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i"); var r = window.location.search.substr(1).match(reg); if (r != null) return unescape(r[2]); return null; };