在IE中,使用 location.href = "xxx.html" ,window.open("xxx.html") 这样的方式跳转页面时,在目标页面中 document.referer的值会是空。我们用两个方法解决
1.form
function URL(url) { if (isIE) { // IE浏览器 var form= document.createElement("form"); form.action = url; form.method = "GET"; document.body.appendChild(form); form.submit(); } else { // 非IE location.href = url; } }
2.模拟a标签
function URL(url, target) { var referer = document.createElement('div'); referer.href = url; referLink.target = target; document.body.appendChild(referLink); if (isIE) { referLink.click(); } else { window.open(url) } }
参考:
https://www.jb51.net/article/52350.htm
https://www.cnblogs.com/qianyee/archive/2011/12/13/2286217.html