Detects if the browser has flash and its version installed

Source: Internet
Author: User

Detects if the browser has flash and its version installed

Here are a few points to be aware of.

1. Get all the Elements
    • Ie:

         
           
          
      1. document.all
    • FireFox:

         
           
          
      1. document.getElementsByTagName(*)
2, check whether the plug-in installation (Flash)
  • ie:
     
         
       
    1. var swf = new activexobject ( ' Shockwaveflash.shockwaveflash '
  • Firefox:
      
         
       
    1. //navigator的首字母必须是小写,大写是不正确的
    2. var swf=navigator.plugins["Shockwave Flash"]

The complete code is as follows:

  
 
  1. /**
  2. * 检测浏览器是否安装了flash; 返回json,f:是否安装;v:若安装,则返回版本号
  3. * @returns {{f: number, v: number}}
  4. */
  5. function checkFlash() {
  6. var hasFlash = 0;
  7. var flashVersion = 0;
  8. var swf = null;
  9. //document.all为IE下,document.getElementsByTagName("*")为非IE
  10. if (document.all || document.getElementsByTagName("*")) {
  11. try {
  12. swf = new ActiveXObject(‘ShockwaveFlash.ShockwaveFlash‘);
  13. if (swf) {
  14. hasFlash = 1;
  15. vswf = SWF getvariable "$version"
  16. flashVersion = parseInt(VSwf.split(" ")[0].split(",")[0]);
  17. }
  18. }
  19. catch (e) {
  20. //catch不能做处理,而且必须要捕捉;
  21. //否则在firefox,下,ActiveXObject会出错,下面的代码不会再去执行
  22. }
  23. if (!swf){
  24. //navigator首字母必须是小写,大写是错误的
  25. if ( navigator plugins && navigator plugins length > 0 ) {
  26. var swf = navigator.plugins["Shockwave Flash"];
  27. if (swf) {
  28. hasFlash = 1;
  29. var words = SWF Span class= "pun". description split
  30. for ( var I = 0 ; I < words length I ++) {
  31. if (isNaN(parseInt(words[i]))) {
  32. continue;
  33. }
  34. flashVersion = parseInt(words[i]);
  35. }
  36. }
  37. }
  38. }
  39. }
  40. return {f: hasFlash, v: flashVersion}
  41. }


From for notes (Wiz)

Detects if the browser has flash and its version installed

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.