Ibrahim
Ibrahim

Reputation: 265

browser back button causes an iframe to be navigated

I have a web-page and withing that page I am using an iFrame. this iFrame contains two buttons previous & next. On next button click I change the source of iFrame to lets say page2.html and on previous button click i change the source back to page1.html. Issue is when i click the browser back and forward buttons it causes the iFrame to navigate (depicting the functionality of those above buttons). How can I avoid this, that is on browser back button click previous page should be loaded (of browser's rather iframe's).

Thanks

Upvotes: 3

Views: 4238

Answers (1)

Ibrahim
Ibrahim

Reputation: 265

I got the solution to the problem. I have to replace the url of the frame by window.location.replace(newurl).

in this case it doesn't add into browser history.

Upvotes: 4

Related Questions