Flash 4 detection script for Plugin and ActiveX
with referral to alternative pages

 

issue: technote 14086 tells you how to use a flash 4 file for scriptless detection of the Flash 4 plugin. however, this does not refer users of IE Windows to an alternative page if they don't have the Flash 4 ActiveX. these users get the autoinstall dialog.

in some cases however you might not want to force the users to autoinstall but refer them to the alternative page as well. there is a Dreamweaver 3 behavior which would do this but if you don't have Dreamweaver 3 her is a simple way to create your own script. simple because it is only a minor alteration of the Ad4Banner HTML that Flash creates.

there are two ways of going about it:

1) you copy the script underneath and put it into the body tag of your HTML page. you will have to alter all the Flash parameters which i highlighted blue and the URL for your alternative page, which is highlighted green.

2) you download the additional Flash 4 HTML templates and install them. then go into "Publish settings", select Flash, HTML and Gif as types and set the HTML template to Ad4Banner.

if you publish this you will get the code as below with the proper parameters for your file. but since you don't want an alternative Gif you have to replace the line

document.write('<IMG SRC="myflash.gif" WIDTH=550 HEIGHT=400 usemap="#myflash" BORDER=0>');

with

window.location='nonflashed.html';

you also can delete the <NOEMBED> tags so you get in fact the script that is represented here.

NOTE: as you probably know, Flash detection via JavaScript will not work on IE Mac. see technote 13765 about how to redirect IE Mac users. you find general info about Flash an IE Mac at technote 13638.

 

here is the script:

<SCRIPT LANGUAGE=JavaScript>
<!--
var plugin = (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"]) ? navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0;
if ( plugin ) {
plugin = parseInt(plugin.description.substring(plugin.description.indexOf(".")-1)) >= 4;
}
else if (navigator.userAgent && navigator.userAgent.indexOf("MSIE")>=0
&& (navigator.userAgent.indexOf("Windows 95")>=0 || navigator.userAgent.indexOf("Windows 98")>=0 || navigator.userAgent.indexOf("Windows NT")>=0)) {
document.write('<SCRIPT LANGUAGE=VBScript\> \n');
document.write('on error resume next \n');
document.write('plugin = ( IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.4")))\n');
document.write('</SCRIPT\> \n');
}
if ( plugin ) {
document.write('<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"');
document.write(' codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=4,0,2,0" ');
document.write(' ID=myflash WIDTH=550 HEIGHT=400>');
document.write(' <PARAM NAME=movie VALUE="myflash.swf"> <PARAM NAME=quality VALUE=high> <PARAM NAME=bgcolor VALUE=#FFFFFF> ');
document.write(' <EMBED src="myflash.swf" quality=high bgcolor=#FFFFFF ');
document.write(' swLiveConnect=FALSE WIDTH=550 HEIGHT=400');
document.write(' TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash">');
document.write(' </EMBED>');
document.write(' </OBJECT>');
} else if (!(navigator.appName && navigator.appName.indexOf("Netscape")>=0 && navigator.appVersion.indexOf("2.")>=0)){
window.location='nonflashed.html';
}
//-->
</SCRIPT>

 

NOTE: this script is HTML formatted so you cannot simply copy paste it. clicke here to download a zipped txt file.

 

1