Determine if the browser installs Flash plugins and versions

Source: Internet
Author: User
Tags html tags versions
 
 
  1. < SCRIPT LANGUAGE="JavaScript">
  2. <!--
  3. var SWF   =   New    ActiveXObject (' Shockwaveflash.shockwaveflash ');
  4. (SWF)? Document.writeln (' You have installed the plugin '): Document.writeln (' You do not install plugins ');
  5. //   -- >     
  6. </ SCRIPT >  

Dynamic loading.

 
 
  1. < OBJECT classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" ID ="Mflash"
  2. codebase = "http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0"  
  3. WIDTH = " the" HEIGHT="A" id="468x60" ALIGN = "" Viewastext >  
  4. < PARAM NAME= quality VALUE= High >  
  5. </ OBJECT >  
  6. < input type= button onclick="Addflash ()" value = "Add" >
  7. < input type= button onclick="mflash.stop ()" value="Stop">
  8. < input type= button onclick=" Mflash.play () " value=play">
  9. < Script >  
  10. function Addflash () {
  11. Mflash.movie = "http://expert.csdn.net/images/ad/WIBU.swf"  ;
  12. Mflash.play ();
  13. }
  14. </ Script >  

There are many ways to detect plugin, because you can't solve the problem with just one method, so there are so many ways

First, the built-in detection
nn and Mac on IE cannot use the following detection, only win on IE can
1, that is, the need to install
In IE tools-internet option-advanced-view inside the on-demand option if it comes into effect, flash Player ActiveX control will be downloaded from MS's website when required by the browser
If not effective, you do not install plugin and directly into the Web page, you will see a cracked box like the small icon, click can also take you to install
2, HTML inside the object tag inside the ClassID and CODEBASE attributes
ClassID is the identity of ActiveX control, such as Flash Player:
clsid:d27cdb6e-ae6d-11cf-96b8-444553540000
CodeBase is the address of the download plugin, such as FLASH4 (if the browser checks that the number behind version is lower than you already have, it will not be installed):
http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=4,0,2,0
These HTML tags are automatically added when you insert them in flash, public or DW.
When the browser executes these tags, it will be tested.

Second, the use of script to detect
This approach is designed to get rid of the limitations of the previous approach, such as the "Check Plug-in" behavior in DW.
This approach is not available on some machines that cannot execute script, such as the previous version of IE4.5 on Mac, ie above WIN31.
There are also some users who are shutting down the scrpit execution.

Third, the use of flash to detect
If the user does not even carry out the scrpit, it can only use this trick. This is also the method of mm own use.
Do a test of HTML, put a SWF inside, there is only one sentence Geturl ("Your real page")
At the same time in the HTML <HEAD> inside put <meta http-equiv= "Refresh" content= "10; Url= "No Flash page Installed" >
If the SWF doesn't take you to the real page within 10 seconds, the instrumented HTML will take you to a page that's not installed.

Four, the last way, let the user choose
This is also the most common, many sites do a portal page, the following has installed plugin small icon

 
 
  1. <!--start VBSCRIPT plugin detection-->  
  2. < SCRIPT LANGUAGE=VBScript >
  3. Private I, X, mm_flashcontrolversion
  4. On Error Resume Next
  5. x  =  NULL  
  6. mm_flashcontrolversion  =  0  
  7. var Flashmode
  8. Flashmode  =  False  
  9. for I  =  5 To 1 Step-1
  10. Set x  =  CreateObject ("Shockwaveflash.shockwaveflash." & i)
  11. mm_flashcontrolinstalled = isobject(x)
  12. If mm_flashcontrolinstalled Then
  13. mm_flashcontrolversion = CStr(i)
  14. Exit for
  15. End If
  16. Next
  17. Flashmode = (mm_flashcontrolversion >= 5)
  18. If Flashmode  =  True Then
  19. document.write "HTML with Flash"
  20. Else
  21. document.write "No flash HTML"
  22. End If
  23. </ SCRIPT >  
  24. < Script type="text/javascript" language="JavaScript" >
  25. <!--start JS detection
  26. Flashmode  =  0  ;
  27. if (navigator.plugins && navigator.plugins.length > 0)
  28. {
  29. if (navigator.plugins["Shockwave Flash"])
  30. {
  31. var plugin_version  =  0  ;
  32. var words  =  Navigator  . plugins["Shockwave Flash"].description.split ("");
  33. For (var i = 0; I < Words.len Gth; ++i)
  34. {
  35. if (isNaN (parseint (words[i)))
  36. Continue
  37. plugin_version = words[i];
  38. }
  39. if (plugin_version >= 5)
  40. {
  41. var plugin  =  Navigator  . plugins["Shockwave Flash"];
  42. var Numtypes  =  plugin  . Length;
  43. For (j = 0; J < numtypes< /c17>J + +)
  44. {
  45. mimetype = plugin[j];
  46. if (mimetype)
  47. {
  48. if (Mimetype.enabledplugin && (mimetype.suffixes.indexOf ("SWF")!=-1))
  49. flashmode = 1;
  50. Mac wierdness
  51. if (navigator.mimetypes["application/x-shockwave-flash"] = = null)
  52. flashmode = 0;
  53. }
  54. }
  55. }
  56. }
  57. }
  58. if (flashmode = 1)
  59. {
  60. document.write (' HTML with Flash ');}
  61. else {
  62. document.write (' No flash HTML '); }

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.