Get the App
SLTechnology News&Howtos  ›  Development  › 

How to solve the problem of document.referrer denying access under IE

Shulou Source: shulou.com Published: 2022-06-03 07:18:23 10月28日 Update

This article mainly explains "how to solve the problem of denied access to document.referrer under IE". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "how to solve the problem of denied access to document.referrer under IE".

It is very convenient to use document.referrer to go back to the source page (also known as the previous page), we do not need to know the complex url of the source page, and the document.referrer will be reloaded when it comes back to the source page, rather than the previous state.

But in IE, use javascript to jump, such as _ window.location.href= "; HTTP referrer,IE browsers that can't get the browser request will report a script error" deny access "because IE empties the document.referrer.

Other major browsers Firefox and Chrome will retain referrer, which means that IE will enjoy the "ministerial" special treatment again:

The copy code is as follows:

Var referLink = document.createElement ('a')

ReferLink.href = url

Document.body.appendChild (referLink)

ReferLink.click ()

The principle is to secretly add a link to the page of the IE browser, and then click on the link automatically, so that referrer can keep it.

Thank you for reading. The above is the content of "how to solve the problem of denied access to document.referrer under IE". After the study of this article, I believe you have a deeper understanding of how to solve the problem of denied access to document.referrer under IE, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Tags: Questions browsers browsing sources learning code content that is links pages previous complex special not used in use mainstream principles treatment ideas situation Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Technology Huawei MariaDB Docker MySQL