2

我的网站布局如下:

{主页 (包含 Flash 广告的 iframe) }

有时恶意 Flash 广告会加载到框架中,并将用户重定向到他们选择的网站。我想他们在 actionscript 中使用 getURL() 函数。

由于我拥有首页以及框架内的页面,因此能够为两者编辑 html,因此无论如何都会阻止 Flash 广告通过 iframe 发送请求以更改顶部位置。

任何帮助,将不胜感激。谢谢。

4

1 回答 1

2

HTML5 来救援!

只需将其添加到您的 iframe 中:

sandbox="allow-scripts"

此 iframe 沙盒功能可防止 iframe 中的任何内容重定向页面或执行任何顶部框架导航。

您想要的一个值是:

allow-scripts - Allows script execution

您不想要的其他三个沙盒选项是:

allow-same-origin - Allows the iframe content to be treated as being from the same origin as the containing document
allow-forms - Allows form submission
allow-top-navigation - Allows the iframe content to navigate (load) content from the containing document

完全“沙盒化”的 iframe:

sandbox=""

功能齐全的 iframe:

sandbox="allow-scripts allow-forms allow-same-origin allow-top-navigation"

(或干脆省略该属性)

于 2012-05-07T21:34:18.983 回答