document.referrer来访页面的url
window.location.href 当前页面的url
在使用这两者并且想要在其后面加参数时应注意:判断window.location.href和window.location.href中是否包含?,包含拼接&,不包含拼接?。
if(document.referrer.indexOf('?')>-1){
window.location.href = document.referrer+'&r='+Math.random();
}
else{
window.location.href = document.referrer+'?r='+Math.random();
}