You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Using history.back() inside of an embedded <iframe> causes full page refresh on parent #3734
I have an application that embeds user content within an <iframe>. Calling history.back, history.forward, or history.go will always cause a full page refresh in the parent window.
Expected Behavior
When I navigate around within that <iframe> calling window.history.back() (inside of the <iframe>) should only change the window.location.href of the <iframe>. It should not affect the parent window at all.
Actual Behavior
Calling window.history.back() inside of an <iframe> causes a full page refresh in the parent window.
Addition Tidbits
In real Chrome and other browsers, when history entries are created by <iframes> going back / forward between those entries will only ever affect the actual <iframe> and will not leak across to parents.
Also, I have nodeIntegration disabled in the BrowserWindow instance.
Also it would be nice if it were publicly accessible from webContents to access the actual history array on the NavigationController instance. I read through the source and saw the array is never exposed.
I'm currently patching the navigation controller object to do this:
I have the same issue with native browser history API when i use IFRAME history.back func in SAFARI on IOS. And it doesn't work for first history event only. For example i open iframe window, click on button and into iframe i change history by pushState. Then if i try go back by history.back() method or by phone's system back button – page is reloaded. But if i change history INTO iframe multiple times, then history.back() works untill the moment i reach the first history change into iframe - then page is reloaded again.
Reacted by soldonii, Anton Bakinowsky and Yu Legang
Activity
brian-mann commentedon Dec 9, 2015
Also it would be nice if it were publicly accessible from
webContentsto access the actualhistoryarray on theNavigationControllerinstance. I read through the source and saw the array is never exposed.I'm currently patching the navigation controller object to do this:
As long as this is added prior to instantiating
new BrowserWindowit'll get picked up as a function on the prototype here: https://github.com/atom/electron/blob/master/atom/browser/api/lib/web-contents.coffee#L55Now we can access that object:
bundyo commentedon Jun 22, 2016
As a temporary fix until upgrading to a fixed version, one can replace the iframe's history.back() with the one of the containing window:
TotallWAR commentedon Jan 22, 2020
I have the same issue with native browser history API when i use IFRAME history.back func in SAFARI on IOS. And it doesn't work for first history event only. For example i open iframe window, click on button and into iframe i change history by pushState. Then if i try go back by history.back() method or by phone's system back button – page is reloaded. But if i change history INTO iframe multiple times, then history.back() works untill the moment i reach the first history change into iframe - then page is reloaded again.