Friday, November 07, 2008

Meta Refresh and Referrer Problem

Hi All,

Just came around the problem that when meta refresh is used referrer is cleared by Firefox, IE and some other browser. Just tested on firefox it cleared. The scenario for me is i have to redirect the user after few second, so i used meta refresh, but client complaint he is not getting referrer. So came up with the quick small javascript code.

// delay parameter is in sec.
// url paramter should be full url including http://
// example usage: delayRedirect(2,'http://localhost/test/referrer.php');
function delayRedirect(delay, url)
{
var delaySec = delay * 1000;
setTimeout("window.location.href='"+url+"'",delaySec);
}

2 comments:

Rafael A said...

Great tip!
But still doesn't work on IE. :-(

Nihlaeth said...

Amazing, thanks!
That I didn't thought of this myself before...