重定向后,IE中的文档document.referrer为空

时间:2011-06-24 13:38:15

标签: javascript internet-explorer

我正在链接到一个页面(第1页),该页面执行重定向最后一页(第2页)。但是在第2页上,document.referrer属性为空,但仅在I.E中,因为重定向。

有没有办法解决这个问题?

由于 范

- 编辑---

页面A只是作为指向页面B的链接。页面B使用window.location重定向到页面C的URL。但是如上所述,在页面B的重定向之后,页面C中的document.referrer属性为空,这是 IE中的情况

另外 - 我只使用http https

1 个答案:

答案 0 :(得分:3)

这似乎是IE的错误,请参阅:http://webbugtrack.blogspot.com/2008/11/bug-421-ie-fails-to-pass-http-referer.html
如果是IE,请创建指向该URL的新链接,然后单击它。

function goto(url){
  if(isIE){
    var referLink = document.createElement('a');
    referLink.href = url;
    document.body.appendChild(referLink);
    referLink.click();    
  }
  else{
      location.href = url;
  }
}