Results 1 to 6 of 6

Thread: Javascript to detect flash player

  1. #1
    Join Date
    Jan 2008
    Location
    Near Chicago
    Posts
    247
    Thanks
    105
    Thanked 2 Times in 2 Posts

    Default 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.
    Last edited by evan; 05-19-2009 at 07:27 PM.

  2. #2
    Join Date
    Feb 2008
    Location
    Cebu City Philippines
    Posts
    1,160
    Thanks
    17
    Thanked 277 Times in 275 Posts

    Default

    A markup solution might be useful:
    Code:
    <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.
    Learn how to code at 02geek

    The more you learn, the more you'll realize there's much more to learn
    Ray.ph!

  3. The Following User Says Thank You to rangana For This Useful Post:

    evan (05-20-2009)

  4. #3
    Join Date
    Jan 2008
    Location
    Near Chicago
    Posts
    247
    Thanks
    105
    Thanked 2 Times in 2 Posts

    Default

    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>
    Last edited by evan; 05-20-2009 at 06:09 PM.

  5. #4
    Join Date
    Jan 2008
    Location
    Near Chicago
    Posts
    247
    Thanks
    105
    Thanked 2 Times in 2 Posts

    Default Now that it works -how did it work?

    It worked like a charm -how? so why would doing this with javascript even be an option?

  6. #5
    Join Date
    Feb 2008
    Location
    Cebu City Philippines
    Posts
    1,160
    Thanks
    17
    Thanked 277 Times in 275 Posts

    Default

    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.
    Learn how to code at 02geek

    The more you learn, the more you'll realize there's much more to learn
    Ray.ph!

  7. The Following User Says Thank You to rangana For This Useful Post:

    evan (05-21-2009)

  8. #6
    Join Date
    Jan 2008
    Location
    Near Chicago
    Posts
    247
    Thanks
    105
    Thanked 2 Times in 2 Posts

    Default

    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.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •