IE在location.replace之后有空的document.referrer [英] IE has empty document.referrer after a location.replace

查看:253
本文介绍了IE在location.replace之后有空的document.referrer的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个网站可以执行复杂的搜索,并且有一个加载页面。在我们使用的加载页面上:

I've got a site that does a complex search and has a "loading" page. On the loading page we use:

< body onload =window.location.replace('results_page.php'); >

或者:

< body onload =window.location ='results_page.php'; >

上述两个选项之间的唯一区别是location.replace()会忽略浏览器历史记录中的页面。

The only difference between the two option above are that location.replace() ignores the page in the browser's history.

在results_page上,我需要阅读引荐来源以进行跟踪:

On the results_page I need to read the referrer for tracking purposes:

< script>警报(document.referrer); < / script>

这适用于除IE之外的所有浏览器,它返回文档的空值。推荐人

This works fine on all browsers except IE, which returns and empty value for document.referrer.

任何人都知道更好的方法来进行javascript重定向,这会给IE一个推荐者的价值吗?

Anyone know a better way to do a javascript redirect that will give IE a value for the referrer?

ps这个例子比生产中的要简单得多。

p.s. This example has been made much more simple than it would be in production.

推荐答案

看起来这只是开展业务的成本与IE用户。没有黑客就无法修复。现在正在努力。感谢收听。

Looks like this is just the cost of doing business with IE users. Can't be fixed without a hack. Working on one now. Thanks for listening.

http://webbugtrack.blogspot.com/2008/11/bug-421-ie-fails-to-pass-http-referer.html

我使用了解决方法来实现此功能。像魅力一样。

I used the workaround to make this function. Works like a charm.

<script type="text/javascript" >            
function redirect(url) {
    if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)){
        var referLink = document.createElement('a');
        referLink.href = url;
        document.body.appendChild(referLink);
        referLink.click();
    } else {
        location.href = url;
    }
}
</script>

这篇关于IE在location.replace之后有空的document.referrer的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆