Home  >  Article  >  Web Front-end  >  javascript检测flash插件是否被禁用的方法_javascript技巧

javascript检测flash插件是否被禁用的方法_javascript技巧

WBOY
WBOYOriginal
2016-05-16 15:20:071498browse

本文实例讲述了javascript检测flash插件是否被禁用的方法。分享给大家供大家参考,具体如下:

<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="Generator" content="EditPlus&reg;">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
<title>Document</title>
  <script>
    function demo(){
      var flag = false;
      if(window.ActiveXObject){
        try{
          var swf = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
          if(swf){
            flag = true;
          }
        }catch(e){
        }
      }else{
        try{
          var swf = navigator.plugins['Shockwave Flash'];
          if(swf){
            flag = true;
          }
        }catch(e){
        }
      }
      if(flag){
        console.log("running ok");
      }else{
        console.log("running error");
      }
    }
  </script>
</head>
<body>
<button onclick="demo();">click</button>
</body>
</html>

希望本文所述对大家JavaScript程序设计有所帮助。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn