//获得页面地址栏传参的值 ( index.jsp?id=123)
function GetQueryString(name){
var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
var r = encodeURI(window.location.search).substr(1).match(reg);
if(r!=null)return decodeURI(unescape(r[2])); return null;
}
//id为页面传值的名称
var id = GetQueryString("id");
console.log(id); //输出的值为123
评论 (0)