2010-02-03 87 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可能證明是有用的。

相關問題