Document.referrer issue on IE when the requests doesn't come from a link [duplicate]

风流意气都作罢 提交于 2019-12-25 08:56:25

问题


Possible Duplicate:
IE has empty document.referrer after a location.replace

Hi there,

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?

Thanks.


回答1:


Store the old page url in a cookie.

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

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

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();


来源:https://stackoverflow.com/questions/5847615/document-referrer-issue-on-ie-when-the-requests-doesnt-come-from-a-link

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!