Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

firefox iframe history

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.

like image 809
pkario Avatar asked Oct 14 '22 15:10

pkario


2 Answers

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.

like image 58
Josef Sábl Avatar answered Oct 19 '22 23:10

Josef Sábl


If the problem is that your entries are duplicated, go

history.back(-2)

or -3, or -4 if needed instead of history.back() or history.back(-1).

But then, if I were you I'd try to ditch the iframes based solution and build something that doesn't involve them at all, since communication between iframes and a parent document tends to be a bug magnet-

like image 41
Carlos Vergara Avatar answered Oct 19 '22 23:10

Carlos Vergara