gpt4 book ai didi

javascript - 无法在沙盒环境中加载 iframe

转载 作者:行者123 更新时间:2023-12-04 04:27:56 25 4
gpt4 key购买 nike

我正在尝试在我的网页中加载启用了沙箱的 iframe,但它显示错误:

An error occured while loading the pad Uncaught SecurityError: Failed to set the 'domain' property on 'Document': Assignment is forbidden for sandboxed iframes.



嵌入 iframe 的代码是:
<iframe 
id="iframe1"
name="iframe1"
src="http://localhost:9002/p/6dN6dkWRmd"
height="700px" width="500px"
sandbox="allow-scripts allow-top-navigation">
</iframe>

在 iframe javascript 中,我发现这段代码抛出错误:

if ((!browser.msie) && (!(browser.mozilla && browser.version.indexOf("1.8.") == 0))) { document.domain = document.domain; // for comet }



谁能解释一下这是什么 document.domain正在做什么,我应该怎么做才能在沙盒环境中运行这个 iframe?

注:没有沙箱它工作正常。

最佳答案

我预计问题是您的 iframe 在本地主机上,请尝试使用另一个域,即使它只是指向您的本地计算机。

关于javascript - 无法在沙盒环境中加载 iframe,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34379012/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com