Javascript fix for the failure of IE to pass HTTP_REFERER in setting new URL on location.href

Setting a new URL using location.href will change the HTTP_REFERER on Firefox/Opera/Safari, but NOT on IE

Here is the hack to fix this (quoted from here):

/* location.href FIX for MSIE */
function setHref(url) {
    var isIE = (navigator.appName.indexOf("Microsoft")!=-1) ? true : false;

    if (!isIE) {
        //Standards based browsers
        parent.location.href = url; // Set target: self. / parent. / top.
    } else {
        var lha = document.getElementById(‘_lha’);
                lha = document.createElement(‘a’);
       = ‘_lha’;
       = ‘_parent’;  // Set target: for IE
            lha.href = url;

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s