简体   繁体   English

如何像模糊图像一样模糊iframe?

[英]How do I blur an iframe like I blur an image?

Is there a way to blur an iframe for a few seconds using jQuery? 有没有一种方法可以使用jQuery将iframe模糊几秒钟? It should look something like a gaussian blur, for example in photoshop. 例如,在Photoshop中,它看起来应该像是高斯模糊。 (here's an example image , see the right side) (这是示例图片 ,请参见右侧)

The link being displayed in the iframe is NOT of the same origin, which is why I have been struggling with this. 在iframe中显示的链接不是同一来源的,这就是为什么我一直为此苦苦挣扎的原因。 It's not possible to modify the iframe's contents. 无法修改iframe的内容。

Is it possible to apply a blur to an iframe of a different origin only for a few seconds using jQuery? 是否可以使用jQuery仅在几秒钟内将模糊应用于其他来源的iframe?

You can blur any element in CSS 3: 您可以模糊CSS 3中的任何元素:

 #iframe-container { -webkit-filter: blur(3px); filter: blur(3px); } 
 <div id="iframe-container"> <iframe src="//example.com"></iframe> </div> 

You can just apply a blur filter via CSS3: 您可以只通过CSS3应用模糊滤镜:

$("iframe").css("filter","blur(5px)")

Don't forget to polyfill the filter attribute. 不要忘记填充过滤器属性。 Maybe you can consider to apply a class to the iframe with the appropiate properties as you can see here 也许你可以考虑一类适用于iframe与此时,相应的属性,你可以看到在这里

iframe.contents().find('body').blur()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM