问题
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