删除iframe会影响某些浏览器中的会话历史记录,但不会影响Chrome中的会话历史记录

问题描述

我有一个页面www.example.com),该页面在模式窗口中显示了跨域iframe(www.another-example.com)。用户通过多个重定向与iframe中的网站进行互动。 iframe中的每个重定向都会将条目添加到浏览器会话历史记录中。点击后退按钮可在iframe中进行导航。如果我们从文档中删除iframe,则某些浏览器(即11,firefox)会从该iframe创建的条目中清除会话历史记录,但是chrome会保留这些多余的条目,并且如果用户单击“后退”按钮,则不会发生任何事情。是虫子吗? 我为此问题创建了一个演示:

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/ 在iframe中单击一些链接,然后将其删除

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...