Removing iframe affects the session history in some browsers but not in Chrome

Viewed 306

I have a page (www.example.com) that shows cross-domain iframe (www.another-example.com) in the modal window. The user interacts with the site in the iframe with multiple redirects. Every redirect inside the iframe adds entries to the browser session history. Clicking the back button cause navigation inside the iframe. If we remove iframe from the document some browsers (ie11, firefox) clear the session history from entries created by that iframe but chrome leaves this extra entries and if the user clicks the back button nothing happends. Is it a bug? I've create a demo for this issue:

html

<h1>iframe test</h1>
  <div>history length <span id="historyLength"></span></div>
<div>
    <button id="deleteButton">remove iframe</button>
</div>
<iframe src="https://www.wikipedia.org/" frameborder="0" height="500" width="500">
    iframe
</iframe>

js

const button = document.getElementById('deleteButton');
const historyLength = document.getElementById('historyLength');

button.addEventListener('click', () => {
  const iframe = document.querySelector('iframe');
  document.body.removeChild(iframe);
})

setInterval(() => {
  historyLength.innerText = window.history.length;
}, 500);

https://jsfiddle.net/xibo/L1oga9bq/2/ Click some links inside the iframe and remove it.

0 Answers
Related