IE document. referrer access denial solution

  • 2020-06-23 00:09:17
  • OfStack

Using document.referrer to go back to the source page (also known as the previous page) is very handy because we don't have to know url, which is a complex source page, and document.referrer will reload when it comes back to the source page, rather than the previous state.

But in IE, javascript is used as the jump, such as window. location. href= ""; The page jumped to could not fetch the requested HTTP referrer. The IE browser will report a script error "denied access" because IE cleared document.referrer.

The other major browsers, Firefox and Chrome, will retain referrer, meaning that IE will once again enjoy "ministerial" privileges:
 
var referLink = document.createElement('a'); 
referLink.href = url; 
document.body.appendChild(referLink); 
referLink.click(); 

The idea is to sneak a link into the IE page and click on it automatically, so referrer stays.

Related articles: