Reputation: 31
Note: There are many questions asked where the poster is writing a new location into the iframe from the outside, and is told to use location.replace. This is not what is going on in my case.
Edit: I left my initial description in below, but I decided to describe the issue again in simpler terms. If I do not have any control over the location change of an iframe, so I cannot use location.replace, how to I stop the iframe from touching the history of the browser?
Original description: My web application is running an angular app in an iframe. User behavior in this angular app often causes new locations to be written to the iframe, which apparently cascades up and adds new items to the browser history. Is there a way to block the iframe from affecting the outer browser in this way, so the history is not touched at all by the inner angular application?
Upvotes: 3
Views: 1941
Reputation: 136
The sandbox attribute of the iframe may solve this problem. Using the sample program of Angular router for testing. As long as the sandbox only sets allow-scripts, the iframe will not affect the navigation of the browser.
<iframe src="your url" sandbox="allow-scripts"></iframe>
Upvotes: 2