function navigateWithReferrer(url)
{
var fakeLink = document.createElement ("a");
if (typeof(fakeLink.click) == 'undefined')
location.href = url; // sends referrer in FF, not in IE
else
{
fakeLink.href = url;
document.body.appendChild(fakeLink);
fakeLink.click(); // click() method defined in IE only
}
}
The trick is that, although location.href navigation (and window.navigate() too) doesn't send a referrer, the IE-only click() method on a hyperlink will send a referrer. So if you create a
hyperlink, set its href, and then click() it with script, you'll get the referrer you want.
hyperlink, set its href, and then click() it with script, you'll get the referrer you want.
Unfortunately the click() method isn't supported on hyperlinks in some versions of Firefox, so you need to check for its presence and use location.href if it's not there. Since location.href sends a referrer on firefox, it works fine.
2 comments:
This method does not work in Mazilla Firefox 5
This method does not work in Mazilla Firefox 5
Post a Comment