January 11, 2010

Bypassing browser history

Ahh, this was interesting thing@work. We've an iframe that opens within a website and its location keeps changing with user interactions. The problem was with all these new urls going into browser's history and interference with the default browser back/forward navigation (back/forward navigation gets enabled for the iframe instead).

Initially i thought it wasn't possible to control this (history object doesn't support it, i knew). But then came this simple thing i used in my first year while experimenting in one of my first few projects.

location.replace(newurl);

Ahh, what a savior. Works well in all the browsers. Here are the details from mozilla on this.

No comments: