How to… do a page redirect and stop the browser from recording the History.

One of the most common issues you encounter when building flash/flex applications it have a browser history for your application. So trying to achieve this (there are several ways, none of which make the topic of this post), it never occurred to me until recently when I had a task to try the other way around. The problem here was to navigate away (redirect) from the current page and not make it possible to return with the back browser, in other words to stop the browser recording the history. Fortunately the solution is quite simple and straightforward and it involves Java Script. Basically all you need to do is instead of assigning new value for the location attribute to use the replace function and replace the current value. If you are inside a flash application just wrap it inside a function for simplicity and call it with ExternalInterface.


function changeLocationWithNoHistory() {
	if (top != window) {
		top.location = window.location;
	}
	
	top.location.replace("http://www.myredirectdomain.com");
}

From inside flash:

ExternalInterface.call("changeLocationWithNoHistory");

Happy redirecting!

Leave a Reply

Your email address will not be published. Required fields are marked *

*