javascript - 阻止对父级的相同域 iframe 访问

标签 javascript iframe parent parent-child same-origin-policy

我有一个带有 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/

相关文章:

javascript - 如何在 JavaScript 中更改 iframe 的源位置?

javascript - 在具有跨源的 iframe 中设置数据属性值

mysql - 如何删除mysql中的父行?

如果子项中的条件为真,jQuery 将类添加到父项

javascript - 如何获取每个角色的位置

javascript - 如何获取字符串变量中具有特定类名的所有范围

html - 加密iframe控件的src属性

jQuery CSS Style a parent div when child is focused

javascript - event.preventDefault() 在 Mozilla 或 IE 中不起作用

Javascript:没有在行动中摸索模数