当请求不是来自链接时,IE上的Document.referrer问题 [英] Document.referrer issue on IE when the requests doesn't come from a link

查看:151
本文介绍了当请求不是来自链接时,IE上的Document.referrer问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


可能重复:

IE在location.replace之后有空文件.referrer

你好,

我在IE中使用document.referrer属性时遇到了问题。当我没有通过链接访问页面而是通过JavaScript更改window.location时,目标页面的document.referrer在IE7 / 8中为空。关于如何绕过它的任何想法?

I have got an issue on using the document.referrer property in IE. When I get to a page not through a link but changing the window.location through JavaScript, the document.referrer of the destination page is empty in IE7/8. Any idea on how to get around it?

谢谢。

推荐答案

将旧页面URL存储在cookie中。

Store the old page url in a cookie.

或者将引用添加到片段标识符中的url。

Or add the referer to the url in the fragment identifier.

location.href = 'page.html' + '#' + location.href

或者使用javascript动态创建一个链接,并将其命名为.click()。所以类似

Or create a link on the fly with javascript, and call it's .click(). So something like

var a = document.createElement('a');
a.href='page.html';
document.body.appendChild(a);//not sure if this is needed
a.click();

这篇关于当请求不是来自链接时,IE上的Document.referrer问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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