Recently, the company website needs to count the data from which pages users enter the registration page. To start, simply get it via $_SERVER['HTTP_REFERER'] (php) on the server side. However, it was found that many registered users did not have a referer value. Later, I checked that if the window.location.href method is used to jump under IE, the referer value is empty. If you jump inside the tag , the referer will not be empty. Therefore, this IE problem can be solved with the following code:
function gotoUrl(url){ if(document.all){ var gotoLink = document.createElement('a'); gotoLink .href = url; document.body.appendChild(gotoLink); gotoLink .click(); } else window.location.href = url; }
The principle is to create a tag , then set the URL address that needs to be redirected, and finally trigger the click event.