2010-02-03 85 views
6

我想知道是否有Javascript方式来检测用户是否安装了任何类型的Flash阻止插件,以便我可以适当地适应这些用户。有没有办法检测Flash拦截器?

例如,我使用'点击闪光',但使用SiFR渲染文本的网站点击“点击闪光”按钮,这变得非常烦人。出于这个原因,我不在我的设计中使用SiFR。但是如果我能发现有安装了闪存阻塞插件,我就不会调用SiFR函数。

任何想法?

+1

我不确定,也没有时间去挖掘更多,但你看过swfobject? http://code.google.com/p/swfobject/ – marcgg 2010-02-03 13:42:42

+0

http://stackoverflow.com/questions/17727766/how-to-check-flash-plugin-is-blocked-in-chrome 或 http://stackoverflow.com/questions/5717062/how-to-detect-flash-using-swfobject – GKislin 2015-07-29 13:10:47

回答

4

看看http://www.adobe.com/support/flash/publishexport/scriptingwithflash/scriptingwithflash_03.html。您可以在页面加载完成后调用以下内容。

var movie = window.document.movie; 
try { 
    //if the movie is blocked then PercentLoaded() should through an exception 
    if (movie.PercentLoaded() > 0) { 
     //Movie loaded or is loading 
    } 
} 
catch (e) { 
    //Movie is blocked 
} 
+0

404,页面不可用 – 2012-09-05 11:39:05

+0

如果有人感兴趣,我在archive.org上归档的页面:https ://web.archive.org/web/20100710000820/http://www.adobe.com/support/flash/publishexport/scriptingwithflash/scriptingwithflash_03.html – nitro2k01 2014-02-05 20:27:19

2

soundmanager2 JS库使用一个电影参考的PercentLoaded功能。
摘录:

return (flash && 'PercentLoaded' in flash ? flash.PercentLoaded() : null); 

有趣的语法笔记...闪光/ ExternalInterface的(的ActiveX/NPAPI)桥接方法不typeof运算“功能”,也不是的instanceof功能,但仍然有效。此外,JSLint不喜欢(Flash中的'PercentLoaded')风格的语法,并建议hasOwnProperty(),在这种情况下不起作用。此外,使用(闪存& flash.PercentLoaded)会导致IE抛出“对象不支持此属性或方法”。因此,必须使用'in'语法。

为了获得对Flash电影的参考,this page可能证明是有用的。

相关问题