例如我有个请求地址:localhost:8081/starry?forwardUrl=succeed&name=1
window.location = getIndexUrl();
获取地址,自动添加到forwardUrl:
function getIndexUrl(name){
var forwardUrl = getQueryString('forwardUrl');
var location = 'index';
if(forwardUrl ){
location = location + '?forwardUrl' + forwardUrl;
}
return location;
}
获取url中的参数:
function getQueryString(name){
var reg = new RegExp("(^|&)" + name + "([^&*])(&|$)");
var r = window.location.search.substr(1).match(reg);
if(r != null ) return unscape(r[2]); return null;
}