Fix IE Back Button when Redirecting

This simple method is useful in situations where you need the IE browser to redirect to other urls and need the back button to bring user back to the origin page.

For example, say that your origin page is "orig.html" with a link to "redir.html" that redirects to "target.html". 

Using the html meta refresh tag,
<meta http-equiv="refresh" content="0;URL=target.html" />
in "redir.html" and clicking on back button when on the target page, would cause IE to load back "redir.html" and redirect to "target.html" and can never get back into the "orig.html".

Using javascript,
window.self.location='target.html';
does the same thing in IE and also in Chrome browser.

The solution: use javascript,
window.self.location.replace('target.html');
to redirect while keeping the back button to work properly. This works on IE, Chrome and Firefox browsers. While
window.top.location.replace('target.html');
would also does the job, your "target.html" will break out from inside frames.

To implement, you can place the script inside the body onload event like below:
<body onload="window.self.location.replace('target.html');">
of course, you can place it anywhere as long as the browser gets to execute the script.

Comments
 - Infomist Services
2009-05-07 09:26:53
Firefox becomes more powerful as compared to IE. I use know Firefox easy and nice.
Name:
Email:
 
Website:
Title:
UBBCode:
[b] [i] [u] [url] [quote] [code] [img] 
 
 
Please input the anti-spam code that you can read in the image.

3.26 Copyright (C) 2008 Compojoom.com / Copyright (C) 2007 Alain Georgette / Copyright (C) 2006 Frantisek Hliva. All rights reserved."

Share This Page

Zone It! Digg It! Save to del.icio.us Reddit this page Add to Facebook Stumble It! Add to Slashdot Prop It Add to Furl Add to Yahoo Add to Blogmarks Add to Technorati Add to Folkd Add to Spurl Add to Google Add to BlinkList

Related Links