【问题标题】:Is there a way to detect Flash blockers?有没有办法检测 Flash 拦截器?
【发布时间】:2010-02-03 13:36:30
【问题描述】:

我想知道是否有一种 Javascript 方法来检测用户是否安装了任何类型的闪存阻止插件,以便我可以适当地容纳这些用户。

例如,我使用“click to flash”,但使用 SiFR 呈现文本的网站到处都是“click to flash”按钮,这变得非常烦人。出于这个原因,我不在我的设计中使用 SiFR。但是,如果我能发现是否安装了闪存阻止插件,我就不会调用 SiFR 函数。

有什么想法吗?

【问题讨论】:

标签: javascript flash plugins


【解决方案1】:

看看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
}

【讨论】:

【解决方案2】:

soundmanager2 JS 库使用电影引用的PercentLoaded 函数。
摘录:

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

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

要获得对 Flash 电影的引用,this page 可能会很有用。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-11-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多