获取URL内参数

  • A+
所属分类:前端分享

function getParam(id,_url){
var url =_url||window.document.location.href;
var url=url.toString();
var u = url.split("?");
var get = {};
if (typeof(u[1]) == "string") {
u = u[1].split("&");
for (var i in u) {
var j = u[i].split("=");
get[j[0]] = j[1];

}

} else {
return;
}
return get[id];
}
想获得啥就传啥。好用不要客气,

文鱼

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: