Javascript – firefox iframe history

firefoxjavascriptweb-applications

In a web app we use IFRAME to let users select items for the parent page.

The problem is that FIREFOX (3.5) adds a copy of the same (parent) page to history each time IFRAME is opened.

The web app is using history.back() to go from parent page to one that called that page.

We can fix that by passing the "back" page as parameter from caller to callee.

Still BACK button remains broken (the user presses back button but remains in same page).

The other problem that is created is that we want some pages out of history. We do not want the user to go back to an INSERT page.

This is easily done with location.replace on the INSERT page when finished, but impossible on FIREFOX with many entries of the same INSERT page.

Best Solution

Not sure if your problem is same as I was having today, but...

When there is an iframe on the page and iframes src changes, the browser (FF 4.0 in my case) considers it to be a navigation and upon pressing the back button, it navigates one step back inside this iframe.

It however behaves differently when you create this iframe dynamically with javascript after the page is loaded. Consecutive changing of iframes src does not count as navigation and browser does not put any pages into history, resulting in expected behavior of back button.