Affects: IE6, IE7, IE8, IE9 RC 1
Status: Microsoft has confirmed this will NOT be fixed in IE8 RTM
Lets take a moment to explain... The HTTP Referer: Identifies the address of the webpage that linked to it... by checking the Referer the new page can identify where the request came from. (and uhm yeah, the intentional mis-spelling of this header is a whole other issue)
(Full Wikipedia Referer Def'n and the HTTP/1.1 spec on Referer)
All good browsers send this header on a request indicating where the request came from. The target page/site can then use that information to track backlinks, gather stats on where their users are coming from, improve their marketing, or even block links from an undesired source. Within a site it is handy also to determine the best place to send a user back to, as they may have arrived from any number of sources.
So, what's all the hoopla about? Well IE doesn't always send it. In fact there are several cases when IE doesn't send it, but the most common is this one.
Example:
<input type="button" value="Edit" onclick="location.href='edit.html';">
If you click that button in any non-IE browser, it will tell you what site/page you just came from. However if you click that button in IE (even if you cross your fingers and click with your left hand) no HTTP Referer information will be sent.
So in the larger picture if you want to do any navigation in JavaScript, be ready for it to not pass the referer.
Known Workarounds: One. If you create your own page navigation function in JavaScript and use it instead you can force IE to send the Referer. (It won't help you obtain it from any other site that doesn't provide their own fix though)
Example Workaround Code:
//use browser sniffing to determine if IE or Opera (ugly, but required)
var isOpera, isIE = false;
if(typeof(window.opera) != 'undefined'){isOpera = true;}
if(!isOpera && navigator.userAgent.indexOf('Internet Explorer')){isIE = true;}
//define for all browsers
function goto(url){
location.href = url;
}
//re-define for IE
if(isIE){
function goto(url){
var referLink = document.createElement('a');
referLink.href = url;
document.body.appendChild(referLink);
referLink.click();
}
}
In this case we define a new function called goto(url) for all the browsers it just sets the location.href to the new value, but in IE we redefine it, so that it creates a link, appends it to the DOM, then simulates a click on that link causing page navigation to occur but since IE does pass the referer on links, the referer is sent to the target page!
(PS for those waiting on the Fish Bicycle, it is coming soon... this bug isn't it)
Related Issues: None.
Submit a bug