2012-04-17 77 views
2

我的网站布局是这样的:防止恶意Flash广告

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

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

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

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

+0

对于嵌入/对象标签,类似'allowcriptaccess =“never”'。 – kirilloid 2012-04-17 20:06:06

+0

如果我将它添加到iframe或embed标签,我认为这会阻止Flash广告运行,因为大多数广告公司都使用JavaScript来调用Flash广告。 – User 2012-04-17 21:44:25

+0

那么总结一下,如果不阻止所有广告的运作,没有什么办法可以做到这一点? – User 2012-05-03 13:38:16

回答

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" 

(或简单地省略该属性)

+2

这可行,但重要的是要注意,它只支持Chrome和Safari(现在)。 http://www.w3schools.com/html5/att_iframe_sandbox.asp – Chris 2012-06-29 03:01:53