function getUrlParam(k)
{
var query = window.location.search.substring(1);
var vars = query.split("&");
for (var i=0;i<vars.length;i++) {
var pair = vars[i].split("=");
if(pair[0] == k){return pair[1];}
}
return(false);
}
例:当前网址url为
www.study365.com/news.html?page=2&category=home
当调用getUrlParam(“page”)时返回2
当调用getUrlParam(“category”)时返回home