有两种方法:比如url为:http://h5.49you.com/reg.html?sid=1&a=2&b=3&c=4
1、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 sid = GetQueryString("sid");
var a = GetQueryString("a");
var b = GetQueryString("b");
var c = GetQueryString("c");
2、var $_GET = (function() {
var url = window.document.location.href.toString();
var u = url.split("?");
if (typeof(u[1]) == "string") {
u = u[1].split("&");
var get = {};
for (var i in u) {
var j = u[i].split("=");
get[j[0]] = j[1];
}
return get;
} else {
return {};
}
})();
var sid=ad = $_GET[‘sid‘];
var a=ad = $_GET[‘a‘];
var b=ad = $_GET[‘b‘];
var c=ad = $_GET[‘c‘];
时间: 2024-11-13 10:37:36