如何在沙盒 iframe 上允许 document.domain? [英] How can I allow document.domain on a sandboxed iframe?

查看:45
本文介绍了如何在沙盒 iframe 上允许 document.domain?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个像这样定义的沙盒 iframe:

I have a sandboxed iframe defined like so:

<iframe sandbox="allow-same-origin allow-scripts allow-popups allow-forms allow-modals" src="...">
</iframe>

当我在 iframe 中设置 document.domain 时,出现以下错误:

When I set document.domain inside the iframe, I get the following error:

Uncaught DOMException: Failed to set the 'domain' property on 'Document': Assignment is forbidden for sandboxed iframes.

如何允许在 iframe 中设置 document.domain?

How can I allow document.domain to be set within the iframe?

推荐答案

(感谢评论回答我自己的问题)

由于您愿意将 document.domain 设置为允许在上下文之间进行访问,这完全违背了沙箱的目的.因此,首先对 iframe 进行沙箱化是没有意义的.

Since you are willing to set the document.domain to allow access between the to contexts, that defeats the purpose of the sandbox altogether. So, there is no point in sandboxing the iframe in the first place.

这篇关于如何在沙盒 iframe 上允许 document.domain?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆