我如何使用 javascript/jQuery/etc 来检测是否安装了 Flash,如果没有,显示一个 div,其中包含通知用户他们需要安装 Flash 的信息?
如何检测 Flash 是否已安装,如果未安装,则显示一个隐藏的 div 通知用户?
IT技术
javascript
jquery
asp.net-mvc
flash
detection
                    2021-02-07 21:48:20
                
                    
                
            
        6个回答
            如果swfobject还不够,或者您需要创建一些更定制的东西,请尝试以下操作:
var hasFlash = false;
try {
    hasFlash = Boolean(new ActiveXObject('ShockwaveFlash.ShockwaveFlash'));
} catch(exception) {
    hasFlash = ('undefined' != typeof navigator.mimeTypes['application/x-shockwave-flash']);
}
它适用于 7 和 8。
如果 Flash 插件只是被禁用但已安装,@Drewid 的回答在我的 Firefox 25 中不起作用。
@invertedSpear 在该答案中的评论适用于 Firefox,但不适用于任何 IE 版本。
所以结合了他们的代码并得到了这个。在 Google Chrome 31、Firefox 25、IE 8-10 中测试。谢谢德鲁德和倒矛:)
var hasFlash = false;
try {
  var fo = new ActiveXObject('ShockwaveFlash.ShockwaveFlash');
  if (fo) {
    hasFlash = true;
  }
} catch (e) {
  if (navigator.mimeTypes
        && navigator.mimeTypes['application/x-shockwave-flash'] != undefined
        && navigator.mimeTypes['application/x-shockwave-flash'].enabledPlugin) {
    hasFlash = true;
  }
}
使用 swfobject。如果已安装,它会用flash灯替换 div。请参阅:http : //code.google.com/p/swfobject/
您可以使用 navigator.mimeTypes。
if (navigator.mimeTypes ["application/x-shockwave-flash"] == undefined)
    $("#someDiv").show ();
jqplugin:http : //code.google.com/p/jqplugin/
$.browser.flash == true