我有一个带有 iframe 的网站 xyz.com,它在 iframe 中加载了 xyz.com/usersubmittedpage.html。
如何阻止内页访问父页。同源策略允许它访问父级中的所有内容。是否有另一种方法可以用来加载此页面,而无需授予它访问父内容的权限,同时将其保留在同一域中。
最佳答案
嗯...
iframe 有沙盒属性:https://developer.mozilla.org/en-US/docs/HTML/Element/iframe#attr-sandbox
But it's only supported (reliably) in Chrome (as of this writing, 9/11/2012). (它将在其他地方得到支持/得到支持,但几乎没有。)
关于javascript - 阻止对父级的相同域 iframe 访问,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12365210/