function getUrlVars() { var vars = {}; var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function (m, key, value) { vars[key] = value; } ); return vars; }
使用如:
http://localhost?name=xxg
getUrlVars()["name"] 返回的值为 xxg
function getUrlVars() { var vars = {}; var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function (m, key, value) { vars[key] = value; } ); return vars; }
使用如:
http://localhost?name=xxg
getUrlVars()["name"] 返回的值为 xxg