检测 FLASH 插件崩溃

2022-01-12 00:00:00 browser crash javascript flash

有没有办法通过javascript检测主流浏览器(firefox,即chrome、safari和opera)中的flash插件崩溃?

Is there any way to detect flash-plugin crashes in major browsers (firefox, ie, chrome, safari and opera) via javascript?

推荐答案

我不确定这是否有效.您可以定期获取对 flash 对象的引用,并检查它是否具有 SetVariable 方法.

I'm not sure whether that works or not. You can periodically get a reference to flash object and check whether it has the method SetVariable.

function checkFlashCrashed() {
   try {
      var tmp = document.getElementById("flashObjectId").SetVariable;
      if(!tmp) {
         alert("Flash crashed");
         return;
      }
   } catch (e) {
      alert("Flash crashed");
      return;
   }
   setTimeout(checkFlashCrashed, 1000); // check it out every one second
}

SetVariable 是一个可以从 Javascript 代码中调用的接口函数.如果 flash 崩溃了,它的界面也应该崩溃.因此,这可能是一个解决方案.

SetVariable is an interface function that can be called from Javascript code. If flash crashes, its interface should crash, too. Hence, that may be a solution.

相关文章