HTTP Header referer mainly tells people where I come from, that is, which page I come from. It can be used to count the source of users who visit this website, and can also be used to prevent hot links. The best way to obtain this thing is js. If you obtain it on the server side (PHP method such as: $_SERVER['HTTP_REFERER']), it is unreliable. People can forge it. It is best to use js. It is difficult for people to forge it.
Method: Use the document.referer method of js to accurately determine the true origin of the web page. Currently, Baidu statistics, Google ads statistics, and CNZZ statistics all use this method. Anti-hotlinking is also very simple. If the source URL is judged in js and it is not from this site, the picture will not be displayed.
As we all know, we web developers hate IE because IE does not support standards and its default behavior outside of standards is often inconsistent with other browsers:
Use javascript to make a jump in IE, for example, use window.location.href = ""; If Google uses document.referrer, it cannot get the HTTP referrer requested by the browser because IE has cleared it
The other mainstream browsers Firefox and Chrome will retain the referrer. There is no way, this means that IE will enjoy "ministerial" special treatment again:
The following code can solve this problem in IE:
//Detect if it is an IE browser, then manually add a referer
The principle is to secretly add a link to the IE browser page, and then automatically click on the link, so the referrer can be retained.