check plugin in browser

 1 //invalid in IE
 2     function hasPlugin(name) {
 3         name = name.toLowerCase();
 4         for (var i = 0; i < navigator.plugins.length; i++) {
 5             if (navigator.plugins[i].name.toLowerCase().indexOf(name) > -1) {
 6                 return true;
 7             }
 8         }
 9 
10         return false;
11     }
12 
13     //only for IE
14     function hasIEPlugin(name) {
15         try {
16             new ActiveXObject(name);
17             return true;
18         } catch (ex) {
19         return false;
20         }
21 }
22 
23 //check Flash in all browser
24 function hasFlash() {
25     var result = hasPlugin("Flash");
26     if (!result) {
27         result = hasIEPlugin("ShockwaveFlash.ShockwaveFlash");
28     }
29     return result;
30 }
31 
32 //check QuickTime in all browser
33 function hasFlash() {
34     var result = hasPlugin("QuickTime");
35     if (!result) {
36         result = hasIEPlugin("QuickTime.QuickTime");
37     }
38     return result;
39 }

 

posted on 2013-05-15 17:04  雷音  阅读(151)  评论(0编辑  收藏  举报

导航