To determine whether the client browser has a Flash plug-in installed in a variety of ways _javascript tips

Source: Internet
Author: User
Tags html tags
Common methods:
Copy Code code as follows:

<script language= "JavaScript" >
<!--
var swf = new ActiveXObject (' Shockwaveflash.shockwaveflash ');
(SWF)? Document.writeln (' You have installed the plugin '): Document.writeln (' You do not install plugins ');
-->
</SCRIPT>
[Code]
Dynamic loading.
[Code]
<object classid= "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" id= "Mflash"
Codebase= "http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0"
Width= "height=" "id=" 468x60 "align=" "viewastext>"
<param name=quality value=high>
</OBJECT>
<input Type=button onclick= "Addflash ()" value= "Add" >
<input Type=button onclick= "Mflash.stop ()" value= "Stop" >
<input Type=button onclick= "Mflash.play ()" value= "Play" >
<script>
function Addflash () {
Mflash.movie= "http://www.jb51.net/images/ad/WIBU.swf";
Mflash.play ();
}
</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
Copy Code code as follows:

<!--start VBSCRIPT plugin detection-->
<script language=vbscript>
Private I, X, mm_flashcontrolversion
On Error Resume Next
x = null
mm_flashcontrolversion = 0
var Flashmode
Flashmode = False
For i = 5 to 1 Step-1
Set x = CreateObject ("Shockwaveflash.shockwaveflash." & i)
mm_flashcontrolinstalled = IsObject (x)
If mm_flashcontrolinstalled Then
Mm_flashcontrolversion = CSTR (i)
Exit for
End If
Next
Flashmode = (mm_flashcontrolversion >= 5)
If Flashmode = True Then
document.write "HTML with Flash"
Else
document.write "No flash HTML"
End If
</SCRIPT><!--End VBSCRIPT PLUGIN detection-->

<script type= "Text/javascript" language= "JavaScript" >
<!--start JS detection
Flashmode = 0;
if (navigator.plugins && navigator.plugins.length > 0)
{
if (navigator.plugins["Shockwave Flash"])
{
var plugin_version = 0;
var words = navigator.plugins["Shockwave Flash"].description.split ("");
for (var i = 0; i < words.length; ++i)
{
if (isNaN (parseint (words[i)))
Continue
Plugin_version = Words[i];
}
if (plugin_version >= 5)
{
var plugin = navigator.plugins["Shockwave Flash"];
var numtypes = plugin.length;
for (j = 0; J < Numtypes; J + +)
{
MimeType = Plugin[j];
if (mimetype)
{
if (Mimetype.enabledplugin && (mimetype.suffixes.indexOf ("SWF")!=-1))
Flashmode = 1;
Mac wierdness
if (navigator.mimetypes["application/x-shockwave-flash"] = = null)
Flashmode = 0;
}
}
}
}
}
if (Flashmode = 1)
{
document.write (' HTML with Flash ');}
else {
document.write (' No flash HTML '); }
End JS Detection-->

The following JavaScript script allows you to detect whether the current browser installs the Flash plug-in and whether the plug-in version meets the requirements.
Copy Code code as follows:

<script language= "JavaScript1.1" >
<!--
U can change this number to check specific version of Flash
var mm_contentversion = 6;
var plugin = (navigator.mimetypes && navigator.mimetypes["Application/x-shockwave-flash"])?
navigator.mimetypes["Application/x-shockwave-flash"].enabledplugin:0;
if (plugin) {
var words = navigator.plugins["Shockwave Flash"].description.split ("");
for (var i = 0; i < words.length; ++i) {
if (isNaN (parseint (words[i)))
Continue
var mm_pluginversion = words[i];
}
var mm_flashcanplay = mm_pluginversion >= mm_contentversion;
}
else if (navigator.useragent && navigator.userAgent.indexOf ("MSIE") >=0 &&
(Navigator.appVersion.indexOf ("Win")!=-1)) {
FS hide this from IE4.5 Mac by splitting the tag
document.write (' <scr ' + ' IPT language=vbscript\> ');
document.write (' On Error Resume Next \ n ');
document.write (' Mm_flashcanplay = (IsObject CreateObject ("Shockwaveflash.shockwaveflash." & MM_contentVersion) ) \ n ');
document.write (' </scr ' + ' ipt\> \ n ');
}
if (Mm_flashcanplay) {
Alert ("Flash detection OK.") U can play. ");
}
else{
Alert ("Flash detection Failed.") Need Download specific version. ");
}
-->
</SCRIPT>

<script>
Own summary of
IE to determine whether to install the plugin
var SwF;
function Ie_flash ()
{
Try
{
var swf=new activexobject ("Shockwaveflash.shockwaveflash");
Alert ("Installed plugins");
}
catch (E)
{
Alert ("No plugins Installed");
}
}
Firefox,chrome to determine whether to install the plugin
function Ff_or_chrome_flash ()
{
var swf=navigator.plugins["Shockwave Flash"];
(SWF)? Alert ("Installed Plugins"): Alert ("No plugins Installed");
}
</script>
Related Article

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.