我正在使用iframe在程序中加载第二个网站。
我为此目的创建了div,其中包含iframe:
<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的previos页面。
我尝试过history.back()
,window.history.back()
,history.go(-1)
命令,但所有命令均无效。我看到相同的iframe页面。
来自文档:
跨域脚本API访问
iframe.contentWindow,
规格:HTML Living Standard § Cross-origin objects。window.parent
,window.open
和window.opener
之类的JavaScript API允许文档直接相互引用。 当两个文档的来源不同时,这些引用为窗口和位置对象提供了[[非常受限的访问权限,如以下两节所述。
有关更多信息,请参阅