Flash Player version Detection)

Source: Internet
Author: User

// V1.7
// Flash Player version Detection
// Detect client browser type
// Copyright 2005-2007 Adobe Systems inconfigurated. All rights reserved.
VaR isie = (navigator. appversion. indexof ("MSIE ")! =-1 )? True: false;
VaR iswin = (navigator. appversion. tolowercase (). indexof ("win ")! =-1 )? True: false;
VaR isopera = (navigator. useragent. indexof ("Opera ")! =-1 )? True: false;

Function controlversion ()
{
VaR version;
VaR AXO;
VaR E;

// Note: New activexobject (strfoo) throws an exception if strfoo isn't in the Registry

Try {
// Version will be set for 7.x or greater players
Axo = new activexobject ("shockwaveflash. shockwaveflash.7 ");
Version = AXO. getvariable ("$ version ");
} Catch (e ){
}

If (! Version)
{
Try {
// Version will be set for 6.x players only
Axo = new activexobject ("shockwaveflash. shockwaveflash.6 ");

// Installed player is some revision of 6.0
// Getvariable ("$ version") crashes for versions 6.0.22 through 6.0.29,
// So we have to be careful.

// Default to the first public version
Version = "win 6, 0 ";

// Throws if allowscripaccess does not exist (introduced in 6.0r47)
Axo. allowScriptAccess = "always ";

// Safe to call for 6.0r47 or greater
Version = AXO. getvariable ("$ version ");

} Catch (e ){
}
}

If (! Version)
{
Try {
// Version will be set for 4.x or 5.x player
Axo = new activexobject ("shockwaveflash. shockwaveflash.3 ");
Version = AXO. getvariable ("$ version ");
} Catch (e ){
}
}

If (! Version)
{
Try {
// Version will be set for 3.x player
Axo = new activexobject ("shockwaveflash. shockwaveflash.3 ");
Version = "Win 3, 0, 18, 0 ";
} Catch (e ){
}
}

If (! Version)
{
Try {
// Version will be set for 2.x player
Axo = new activexobject ("shockwaveflash. shockwaveflash ");
Version = "win ";
} Catch (e ){
Version =-1;
}
}
 
Return version;
}

// JavaScript helper required to detect Flash Player Plugin version information
Function getswfver (){
// NS/Opera version> = 3 check for Flash Plugin in plugin Array
VaR flashver =-1;

If (navigator. plugins! = NULL & navigator. plugins. length> 0 ){
If (navigator. plugins ["Shockwave Flash 2.0"] | navigator. plugins ["Shockwave Flash"]) {
VaR swver2 = navigator. plugins ["Shockwave Flash 2.0"]? "2.0 ":"";
VaR flashdescription = navigator. plugins ["Shockwave Flash" + swver2]. description;
VaR descarray = flashdescription. Split ("");
VaR temparraymajor = descarray [2]. Split (".");
VaR versionmajor = temparraymajor [0];
VaR versionminor = temparraymajor [1];
VaR versionrevision = descarray [3];
If (versionrevision = ""){
Versionrevision = descarray [4];
}
If (versionrevision [0] = "D "){
Versionrevision = versionrevision. substring (1 );
} Else if (versionrevision [0] = "R "){
Versionrevision = versionrevision. substring (1 );
If (versionrevision. indexof ("D")> 0 ){
Versionrevision = versionrevision. substring (0, versionrevision. indexof ("D "));
}
}
VaR flashver = versionmajor + "." + versionminor + "." + versionrevision;
}
}
// MSN/WebTV 2.6 supports flash 4
Else if (navigator. useragent. tolowercase (). indexof ("WebTV/2.6 ")! =-1) flashver = 4;
// Web TV 2.5 supports flash 3
Else if (navigator. useragent. tolowercase (). indexof ("WebTV/2.5 ")! =-1) flashver = 3;
// Older WebTV supports flash 2
Else if (navigator. useragent. tolowercase (). indexof ("WebTV ")! =-1) flashver = 2;
Else if (isie & iswin &&! Isopera ){
Flashver = controlversion ();
}
Return flashver;
}

// When called with reqmajorver, reqminorver, reqrevision returns true if that version or greater is available
Function detectflashver (reqmajorver, reqminorver, reqrevision)
{
Versionstr = getswfver ();
If (versionstr =-1 ){
Return false;
} Else if (versionstr! = 0 ){
If (isie & iswin &&! Isopera ){
// Given "win 2, 0, 0, 11"
Temparray = versionstr. Split (""); // ["win", ","]
Tempstring = temparray [1"
Versionarray = tempstring. Split (","); // ['2', '0', '0', '11']
} Else {
Versionarray = versionstr. Split (".");
}
VaR versionmajor = versionarray [0];
VaR versionminor = versionarray [1];
VaR versionrevision = versionarray [2];

// Is the major. Revision> = requested major. Revision and the minor version> = requested minor
If (versionmajor> parsefloat (reqmajorver )){
Return true;
} Else if (versionmajor = parsefloat (reqmajorver )){
If (versionminor> parsefloat (reqminorver ))
Return true;
Else if (versionminor = parsefloat (reqminorver )){
If (versionrevision> = parsefloat (reqrevision ))
Return true;
}
}
Return false;
}
}

Function ac_addextension (SRC, ext)
{
If (SRC. indexof ('? ')! =-1)
Return SRC. Replace (/\? /, Ext + '? ');
Else
Return SRC + ext;
}

function ac_generateobj (objattrs, Params, embedattrs)
{< br> var STR = '';
If (isie & iswin &&! Isopera)
{< br> STR + = ' for (var I in objattrs)
{< br> STR + = I + '= "' + objattrs [I] + '"';
}< br> STR + = '> ';
for (var I in Params)
{< br> STR + = ' ';
}< br> STR + = '';
}< br> else
{< br> STR + = ' for (var I in embedattrs)
{< br> STR + = I + '= "' + embedattrs [I] + '"';
}< br> STR + = '> ';
}

Document. Write (STR );
}

Function ac_fl_runcontent (){
VaR ret =
Ac_getargs
(Arguments, ". SWF", "movie", "CLSID: d27cdb6e-ae6d-11cf-96b8-444553540000"
, "Application/X-Shockwave-flash"
);
Ac_generateobj (Ret. objattrs, Ret. Params, Ret. embedattrs );
}

Function ac_sw_runcontent (){
VaR ret =
Ac_getargs
(Arguments, ". DCR", "src", "CLSID: 166b1bca-3f9c-11cf-8075-444553540000"
, Null
);
Ac_generateobj (Ret. objattrs, Ret. Params, Ret. embedattrs );
}

Function ac_getargs (ARGs, ext, srcparamname, classid, mimetype ){
VaR ret = new object ();
Ret. embedattrs = new object ();
Ret. Params = new object ();
Ret. objattrs = new object ();
For (VAR I = 0; I <args. length; I = I + 2 ){
VaR currarg = ARGs [I]. tolowercase ();

Switch (currarg ){
Case "classid ":
Break;
Case "pluginspage ":
Ret. embedattrs [ARGs [I] = ARGs [I + 1];
Break;
Case "src ":
Case "movie ":
ARGs [I + 1] = ac_addextension (ARGs [I + 1], ext );
Ret. embedattrs ["src"] = ARGs [I + 1];
Ret. Params [srcparamname] = ARGs [I + 1];
Break;
Case "onafterupdate ":
Case "onbeforeupdate ":
Case "onblur ":
Case "oncellchange ":
Case "onclick ":
Case "ondblclick ":
Case "ondrag ":
Case "ondragend ":
Case "ondragenter ":
Case "ondragleave ":
Case "ondragover ":
Case "ondrop ":
Case "onfinish ":
Case "onfocus ":
Case "onhelp ":
Case "onmousedown ":
Case "onmouseup ":
Case "onmouseover ":
Case "onmousemove ":
Case "onmouseout ":
Case "onkeypress ":
Case "onkeydown ":
Case "onkeyup ":
Case "onLoad ":
Case "onlosecapture ":
Case "onpropertychange ":
Case "onreadystatechange ":
Case "onrowsdelete ":
Case "onrowenter ":
Case "onrowexit ":
Case "onrowsinserted ":
Case "onstart ":
Case "onscroll ":
Case "onbeforeeditfocus ":
Case "onactivate ":
Case "onbeforedeactivate ":
Case "ondeactivate ":
Case "type ":
Case "codebase ":
Case "ID ":
Ret. objattrs [ARGs [I] = ARGs [I + 1];
Break;
Case "width ":
Case "height ":
Case "align ":
Case "vspace ":
Case "hspace ":
Case "class ":
Case "title ":
Case "accesskey ":
Case "name ":
Case "tabindex ":
Ret. embedattrs [ARGs [I] = ret. objattrs [ARGs [I] = ARGs [I + 1];
Break;
Default:
Ret. embedattrs [ARGs [I] = ret. Params [ARGs [I] = ARGs [I + 1];
}
}
Ret. objattrs ["classid"] = classid;
If (mimetype) ret. embedattrs ["type"] = mimetype;
Return ret;
}

 

 

/*

After Flash CS3 is installedProgramWhen a static page is published, a JS file is automatically generated in the same level folder.

HTML page:

<NoScript> <object classid = "CLSID: D27CDB6E-AE6D-11cf-96B8-444553540000" codebase = "http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width = "1004" Height = "154">
<Param name = "movie" value = "aa.swf"/>
<Param name = "quality" value = "high"/>
<Embed src = "aaaa.swf" Quality = "high" pluginspage = "http://www.adobe.com/shockwave/download/download.cgi? P1_prod_version = shockwaveflash "type =" application/X-Shockwave-flash "width =" 1004 "Height =" 154 "> </embed>
</Object> </NoScript>

*/

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.