【问题标题】:cannot navigate on the history of iframe content无法浏览 iframe 内容的历史记录
【发布时间】:2020-02-18 22:12:43
【问题描述】:

我正在使用 iframe 在我的程序中加载第二个网站。

我为此目的创建了带有 iframe 的 div:

<div id='ktmv-help'>
    <iframe id="contextHelp" allowTransparency="true" scrolling="no"
            frameborder="0">
    </iframe>
</div>

当我在程序的页面之间导航时,我正在使用 $('#contextHelp')[0].contentWindow.location.replace(url); 命令以编程方式更改 iframe 的内容。

问题是通过$('#contextHelp')[0].contentWindow.location.replace(url); 命令更改内容后,我无法返回 iframe 的上一页。

我尝试了history.back()window.history.back()history.go(-1) 命令,但它们都不起作用。我看到相同的 iframe 页面。

【问题讨论】:

    标签: javascript iframe browser-history


    【解决方案1】:

    来自文档:

    跨域脚本API访问

    iframe.contentWindowwindow.parentwindow.openwindow.opener 等 JavaScript API 允许文档直接相互引用。 当两个文档的来源不同时,这些引用提供对 Window 和 Location 对象的非常有限的访问,如下两节所述。

    规格:HTML Living Standard § Cross-origin objects

    有关详细信息,请参阅

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-01-09
      • 1970-01-01
      • 1970-01-01
      • 2015-02-05
      • 2015-06-14
      • 2022-01-19
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多