July 22, 2009

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

Filed under: Javascript — Tags: , , , , — hoball @ 12:49 pm

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.id = ‘_lha’;
                lha.target = ‘_parent’;  // Set target: for IE
            lha.href = url;

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s

Create a free website or blog at WordPress.com.

%d bloggers like this: