PDA

View Full Version : Flash Page Redirect if no Flash Plugin



kuraldesign
04-21-2010, 04:14 PM
Good Afternoon,

I have a flash intro http://kuraldesign.com/beta/kd/ that needs a redirect to http://kuraldesign.com/beta/kd/home.html if there is no flash plugin i.e. iphone.

Thanks
Karl

jscheuer1
04-22-2010, 01:50 AM
I dont't know about the iphone. I'm sure there are other situations where Flash may not be present. Basically what you need is a way to detect Flash, perhaps even a minimum Flash version.

Now, you've posted this in javascript, or at least that's where I found it. If we use javascript, users without javascript enabled/available will not benefit from whatever we do here, unless we add some HTML into the mix.

Here's a javascript Flash version detection routine:


/* Flash Version Detect Script 2010 John Davenport Scheuer
as first seen in http://www.dynamicdrive.com/forums/
username: jscheuer1 - This Notice Must Remain for Legal Use
*/

function detectFlashVersion(v){
var flashVersionIsInstalled = false;
if(typeof ActiveXObject !== 'undefined'){
// Check ActiveXObject for Flash version capability
/*@cc_on @*/
/*@if(@_jscript_version >= 5)
try {
flashVersionIsInstalled = new ActiveXObject('ShockwaveFlash.ShockwaveFlash.' + v);
} catch (e) {}
@end @*/
if(flashVersionIsInstalled){
flashVersionIsInstalled = true;
}
} else {
// Check navigator.plugins for "Shockwave Flash"
var p = navigator.plugins, i = p.length - 1, re = /Shockwave Flash/;
for (i; i > -1; --i){
if(re.test(p[i].name)){
flashVersionIsInstalled = p[i];
break;
}
}
if(flashVersionIsInstalled){
flashVersionIsInstalled = parseInt(flashVersionIsInstalled['description'].replace(/[^\d\.]/g, '')) >= v;
}
}
return flashVersionIsInstalled;
}

It will return false if the user doesn't have at least the minimum specified version of Flash installed, which includes returning false if there is no Flash installed. To get it to redirect to another page, do (for Flash 8, a popular minimum Flash version for many things):


if(!detectFlashVersion(8)){
location.replace('http://kuraldesign.com/beta/kd/home.html');
}

Optional Extra Stuff for Dealing with Users with no Javascript:

As for dealing with users that don't have either Flash or javascript, here's one way - Make your Flash tag like:


<object id="thePlayer" type="application/x-shockwave-flash" style="height:250px;width:300px;" data="pathto/flash.swf">
<param name="movie" value="pathto/flash.swf">
<param name="allowFullScreen" value="false"><!-- optional -->
<param name="wmode" value="transparent"><!-- optional -->
<param name="allowscriptaccess" value="always"><!-- optional -->
<param id="network" name="allowNetworking" value="external"><!-- optional -->
<div>
Failure - Adobe Flash Application Failure. Make sure you have the latest version player:<br><a target="_blank" href="http://get.adobe.com/flashplayer/" title="Get Free Adobe Flash Player">Free Adobe Flash Player</a><br>&nbsp;<br>Or, You may skip this Flash intro and go to the Home page:<br><a href="http://kuraldesign.com/beta/kd/home.html" title="Skip Flash Intro">Home</a>
</div>
</object>

Just be sure to replace the two highlighted sections with the actual path to your Flash file, and to set its actual height and width in the style attribute.