Home > Web Front-end > JS Tutorial > Implement location.href through a under IE to obtain the value of referer_javascript skills

Implement location.href through a under IE to obtain the value of referer_javascript skills

WBOY
Release: 2016-05-16 16:37:11
Original
1814 people have browsed it

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; 
}
Copy after login

The principle is to create a tag , then set the URL address that needs to be redirected, and finally trigger the click event.

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template