Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 852
Ibrahim Avatar asked Apr 17 '26 09:04

Ibrahim


1 Answers

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.

like image 156
Ibrahim Avatar answered Apr 19 '26 22:04

Ibrahim