Home >Web Front-end >JS Tutorial >Implement location.href through a under IE to obtain the value of referer_javascript skills
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 3499910bf9dac5ae3c52d5ede73834855db79b134e9f6b82c0b36e0489ee08ed, 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 3499910bf9dac5ae3c52d5ede7383485, then set the URL address that needs to be redirected, and finally trigger the click event.