日期:2014-05-16 浏览次数:20399 次
var P_id=request($("a").attr("href"),"id"); var P_pageid=request($("a").attr("href"),"page"); //根据QueryString参数名称获取值 function request(winhref, para) { var subflag=winhref.lastIndexOf('?'); var params = winhref.substring(subflag + 1).split('&'); for (var i = 0; i < params.length; i++) { var pars = params[i].split('='); if (pars[0] == para) { if (pars.length > 1) { return pars[1]; } else { return ""; } } } return ""; }
------解决方案--------------------
function urlParam(name,url){
var results = new RegExp('[\\?&]' + name + '=([^&#]*)').exec(url);
if (!results) { return null; }
return results[1] || null;
}
var url="/xxx/xxx/xx?id=519&page=1";
alert(urlParam('id',url))
alert(urlParam('page',url))
------解决方案--------------------
id = url.split('&')[0].split('=')[1];
page = url.split('&')[1].split('=')[1]