View Full Version : Javascript to detect flash player
I am looking for a script (or link that explains how to do it) that will detect weather the user has a flash player running or not.
I don't want it to offer the option to install the player, rather I want it to:
detect if the user does not have it and simply trigger an event(as in swap out the swf for a static graphic or make the div containing the swf not visible)
this way the user doesn't have to take time to load a player.
I can use this in a function:
if (pluginlist.indexOf("Flash")!=-1)
document.write("You have flash installed")
but is that all I need -I have been looking at more complicated examples that look for all versions for different browsers.
rangana
05-20-2009, 01:27 AM
A markup solution might be useful:
<object type="application/x-shockwave-flash" width="225px" height="265px" data="http://example.com/flash/tearoom.swf">
<param name="movie" value="http://example.com/flash/tearoom.swf" />
<param name="quality" value="high" />
<h1>You don't have flash on your machine</h1>
</object>
If there is no flash installed, the markup inside the object tag will be seen then, otherwise, the flash will become visible and the markup hidden.
Hope that helps.
a different approach...
Initailly I have two divs.
a static logo and a flash version of the logo.
So I opted to make two divs and run a javascript to check for flash then have it make the div holding the flash (with the z-index set so it's in front) invisible after javascript did it's check and if there was no flash player detected -using getElementId.
I tried it and it works!:
<object type="application/x-shockwave-flash" width="225px" height="265px" data="http://example.com/flash/tearoom.swf">
<param name="movie" value="http://example.com/flash/tearoom.swf" />
<param name="quality" value="high" />
<div id="masthead"> <!--contains static logo --> </div>
</object>
It worked like a charm -how? so why would doing this with javascript even be an option?
rangana
05-20-2009, 06:51 PM
If there is a way to do things without JS, then it's better to opt it first. JS can be disabled anytime, while pure mark-up/server-side scripts won't be controlled by user.
Hop that makes sense.
This line seemed intresting since there is no example.com or any file name tearoom.swf -so what does putting it there do?
<param name="movie" value="http://example.com/flash/tearoom.swf" />
re: javascript -I have been hearing that.
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.