//获取location中指定值
- function getLocationValue(name){
- var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
var r = window.location.search.substr(1).match(reg);
if(r!=null)return decodeURI(r[2]); return null;
}
var id = getLocationValue("id"); //直接获取url中的字段
可同时获取url中的多个字段值。