SitePoint Sponsor

User Tag List

Results 1 to 14 of 14

Thread: detecting flash

  1. #1
    Serial Publisher silver trophy aspen's Avatar
    Join Date
    Aug 1999
    Location
    East Lansing, MI USA
    Posts
    12,939
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I need to write a script that detects if a person has flash installed and if they do then do something, if not do something else.

    I can do this no problem with javascript - except for the detecting flash part. I have no idea how to have a js detect flash - or even if its possible.
    Chris Beasley - I publish content and ecommerce sites.
    Featured Article: Free Comprehensive SEO Guide
    My Guide to Building a Successful Website
    My Blog|My Webmaster Forums

  2. #2
    SitePoint Zealot
    Join Date
    Sep 2000
    Location
    Birmingham, AL
    Posts
    120
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I've had the same problem...but I ended up doing a redirect using flash...

    http://www.macromedia.com/support/fl..._detection.htm
    Joseph Schell
    AMICO-Online

  3. #3
    Serial Publisher silver trophy aspen's Avatar
    Join Date
    Aug 1999
    Location
    East Lansing, MI USA
    Posts
    12,939
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I dont need to do a redirect.

    This is for a flash advertisement that I want to popup in a new window. And I also need to set a cookie when I pop it up too. But I only want the window to popup if the user has flash installed.
    Chris Beasley - I publish content and ecommerce sites.
    Featured Article: Free Comprehensive SEO Guide
    My Guide to Building a Successful Website
    My Blog|My Webmaster Forums

  4. #4
    Serial Publisher silver trophy aspen's Avatar
    Join Date
    Aug 1999
    Location
    East Lansing, MI USA
    Posts
    12,939
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    nevermind - found it

    Code:
    <SCRIPT LANGUAGE="JavaScript">
    <!-- use this comment tag to hide the enclosed code from old browsers.
    
    //Look for a version of Internet Explorer that supports ActiveX (i.e., one that's
    //running on a platform other than Mac or Windows 3.1) or a browser that supports
    //the plugin property of the navigator object and that has Flash Player 2.0
    //installed.
    
    if ((navigator.appName == "Microsoft Internet Explorer" &&
        navigator.appVersion.indexOf("Mac") == -1 && 
        navigator.appVersion.indexOf("3.1") == -1) ||
    
        (navigator.plugins && navigator.plugins["Shockwave Flash"])
                           || navigator.plugins["Shockwave Flash 2.0"]){
    
       //Load a pre-defined HTML page with Flash Player in it into the browser window.
        window.location='flashed.html';
    }
    else {
        //Load a pre-defined HTML page without Flash Player into the browser window.
        window.location='nonflashed.html';
    }
    
    // Close the comment tag. -->
    </SCRIPT>
    Chris Beasley - I publish content and ecommerce sites.
    Featured Article: Free Comprehensive SEO Guide
    My Guide to Building a Successful Website
    My Blog|My Webmaster Forums

  5. #5
    Serial Publisher silver trophy aspen's Avatar
    Join Date
    Aug 1999
    Location
    East Lansing, MI USA
    Posts
    12,939
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    if (navigator.mimeTypes && navigator.mimeTypes.length)
    {
    x = navigator.mimeTypes['application/x-shockwave-flash'];
    if (x && x.enabledPlugin) flashinstalled = 2;
    else flashinstalled = 1;
    }

    This wont work for NS.

    And yes it has both javascript and flash installed - and I double checked and it has that correct mime type so why wont this work?
    Chris Beasley - I publish content and ecommerce sites.
    Featured Article: Free Comprehensive SEO Guide
    My Guide to Building a Successful Website
    My Blog|My Webmaster Forums

  6. #6
    JavaScript Guru (Big Ego) Arielladog's Avatar
    Join Date
    Jul 1999
    Location
    SC, USA
    Posts
    390
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Check this out:

    http://javascriptcity.com/forums/sho...?threadid=2215

    The script you have for IE actually just says if it's IE above this version, it's ok, but what the script I posted does is checks for IE, and it also uses navigator.plugins[] to check for NN.

    aDog

  7. #7
    Serial Publisher silver trophy aspen's Avatar
    Join Date
    Aug 1999
    Location
    East Lansing, MI USA
    Posts
    12,939
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    if(navigator.appName=="Netscape"){ 
    var fb=navigator.plugins["Shockwave Flash"].description; 
    var fv=Math.round(fb.charAt(fb.indexOf(".") - 1)); 
    if(fv==5){ 
    youhaveflash(); 
    }else{ 
    noflash(); 
    }}else{ 
    var swf = new ActiveXObject('ShockwaveFlash.ShockwaveFlash.5'); 
    if(swf){ 
    youhaveflash(); 
    }else{ 
    noflash(); 
    }} 
    </script>
    The key part of yours is navigator.plugins["Shockwave Flash"]

    I use the same criteria in scripts above and it does not work.
    Chris Beasley - I publish content and ecommerce sites.
    Featured Article: Free Comprehensive SEO Guide
    My Guide to Building a Successful Website
    My Blog|My Webmaster Forums

  8. #8
    JavaScript Guru (Big Ego) Arielladog's Avatar
    Join Date
    Jul 1999
    Location
    SC, USA
    Posts
    390
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey,

    Are you sure my script doesn't work...I'm almost sure it has in the past for many people.

    aDog

  9. #9
    Serial Publisher silver trophy aspen's Avatar
    Join Date
    Aug 1999
    Location
    East Lansing, MI USA
    Posts
    12,939
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well - actually yes it does work.

    I wonder why mine didn't.
    Chris Beasley - I publish content and ecommerce sites.
    Featured Article: Free Comprehensive SEO Guide
    My Guide to Building a Successful Website
    My Blog|My Webmaster Forums

  10. #10
    Serial Publisher silver trophy aspen's Avatar
    Join Date
    Aug 1999
    Location
    East Lansing, MI USA
    Posts
    12,939
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    var flashinstalled = 0;
    
    if(navigator.appName=="Netscape"){ 
    if(navigator.plugins["Shockwave Flash"]){ 
    flashinstalled = 2;
    }}
    
    if(flashinstalled == 2){
    alert("You have Flash");
    DisplayInfo();
    }
    Okay - this does not work.

    If I move the alert up into the other if statement I get the alert, but down where it is I don't - and I don't get the function either.
    Chris Beasley - I publish content and ecommerce sites.
    Featured Article: Free Comprehensive SEO Guide
    My Guide to Building a Successful Website
    My Blog|My Webmaster Forums

  11. #11
    Serial Publisher silver trophy aspen's Avatar
    Join Date
    Aug 1999
    Location
    East Lansing, MI USA
    Posts
    12,939
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    now nothing works again.

    Code:
    if(navigator.appName=="Netscape"){ 
    if(navigator.plugins["Shockwave Flash"]) 
    {
    alert("You have Flash");
    }else{ 
    alert("You don't have Flash"); 
    }}
    Chris Beasley - I publish content and ecommerce sites.
    Featured Article: Free Comprehensive SEO Guide
    My Guide to Building a Successful Website
    My Blog|My Webmaster Forums

  12. #12
    Serial Publisher silver trophy aspen's Avatar
    Join Date
    Aug 1999
    Location
    East Lansing, MI USA
    Posts
    12,939
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I removed all the rest of the js from the page and still it doesn't work....
    Chris Beasley - I publish content and ecommerce sites.
    Featured Article: Free Comprehensive SEO Guide
    My Guide to Building a Successful Website
    My Blog|My Webmaster Forums

  13. #13
    JavaScript Guru (Big Ego) Arielladog's Avatar
    Join Date
    Jul 1999
    Location
    SC, USA
    Posts
    390
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey,

    I really have no reason why those wouldn't work for you. I'm not the best with plug-ins, but I'll assume your code is correct. Here's how I'd do it ... one of two ways. Hopefully both of them should work.

    Code:
    var flashinstalled = 0;
    
    if(navigator.appName=="Netscape" && navigator.plugins["Shockwave Flash"]){ 
    flashinstalled = 1;
    }
    
    if(flashinstalled){
    alert("You have Flash");
    DisplayInfo();
    }
    or:

    Code:
    if(navigator.appName=="Netscape" && navigator.plugins["Shockwave Flash"]){ 
    alert("You have Flash");
    DisplayInfo();
    }
    Hope that helps,
    aDog

  14. #14
    Serial Publisher silver trophy aspen's Avatar
    Join Date
    Aug 1999
    Location
    East Lansing, MI USA
    Posts
    12,939
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    its actually working now.

    Don't you love netscape inconsistencies?
    Chris Beasley - I publish content and ecommerce sites.
    Featured Article: Free Comprehensive SEO Guide
    My Guide to Building a Successful Website
    My Blog|My Webmaster Forums


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
  •