Document.referrer issue on IE when the requests do

2019-09-04 16:47发布

问题:

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