SitePoint Sponsor

User Tag List

Results 1 to 8 of 8

Thread: Sniffing Flash

  1. #1
    SitePoint Member
    Join Date
    Sep 2001
    Location
    London, UK
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Sniffing Flash

    Is there a way to use JavaScript to sniff for the flash plug-in in IE?

    Basically, I want to do a flash splash above a login - but if the browser doesn't have flash then show a static (don't want them to download it if they don't have it).

    Josh

  2. #2
    Gone!
    Join Date
    Aug 2001
    Location
    Witty Location Parody
    Posts
    3,889
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The way I do it is use Dreamweavers built in Flash Detection in a blank html page. The script will run and redirect the user without them really knowing.

    If they have Flash it will redirect them to loginflash.htm, and if they dont then to loginstatic.htm or whatever, which you can set accordingly. If you dont have dreamweaver the code is below.
    Code:
    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <script language="JavaScript">
    <!--
    function MM_checkPlugin(plgIn, theURL, altURL, autoGo) { //v4.0
      var ok=false; document.MM_returnValue = false;
      with (navigator) if (appName.indexOf('Microsoft')==-1 || (plugins && plugins.length)) {
        ok=(plugins && plugins[plgIn]);
      } else if (appVersion.indexOf('3.1')==-1) { //not Netscape or Win3.1
        if (plgIn.indexOf("Flash")!=-1 && window.MM_flash!=null) ok=window.MM_flash;
        else if (plgIn.indexOf("Director")!=-1 && window.MM_dir!=null) ok=window.MM_dir;
        else ok=autoGo; }
      if (!ok) theURL=altURL; if (theURL) window.location=theURL;
    }
    //-->
    </script>
    </head>
    
    <body bgcolor="#FFFFFF" text="#000000" onLoad="MM_checkPlugin('Shockwave Flash','loginflash.htm','loginstatic.htm',false);return document.MM_returnValue">
    </body>
    <script name="Used by MM_checkPlugin" language="javascript">
    <!--
    with (navigator) if (appName.indexOf('Microsoft')!=-1 && appVersion.indexOf('Mac')==-1) document.write(''+
    '<scr'+'ipt language="VBScript">\nOn error resume next\n'+
    'MM_dir = IsObject(CreateObject("SWCtl.SWCtl.1"))\n'+
    'MM_flash = NOT IsNull(CreateObject("ShockwaveFlash.ShockwaveFlash"))\n</scr'+'ipt>');
    //-->
    </script>
    </html>

  3. #3
    SitePoint Wizard creole's Avatar
    Join Date
    Oct 2000
    Location
    Nashvegas Baby!
    Posts
    7,845
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Or you could simply use Flash to detect Flash. Put a 10x10 movie clip on a page with a GET URL action. IF the user has Flash installed, then Flash will take over and take them to the proper page. If they don't then you put a META refresh or something like that on the page to take them to ths static version.
    Adobe Certified Coldfusion MX 7 Developer
    Adobe Certified Advanced Coldfusion MX Developer
    My Blog (new) | My Family | My Freelance | My Recipes

  4. #4
    SitePoint Member
    Join Date
    Sep 2001
    Location
    London, UK
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks guys.

    Creole - wouldn't your suggestion result in IE trying to download the ActiveX for flash or is this additional code that needs to be placed on the page?

    J

  5. #5
    SitePoint Zealot pnathan's Avatar
    Join Date
    Sep 2001
    Location
    Amsterdam
    Posts
    160
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This is what I use. I have a feeling that Creole's suggestion would create a trap site! This will check if the browser has flash, if it does, the script sends the flash to the browser, if not, the script sends an image to the browser.

    <!--For Netscape-->
    <SCRIPT LANGUAGE=JavaScript>
    <!--
    if(navigator.appName == "Netscape" && navigator.plugins && navigator.plugins["Shockwave Flash"]) {
    var desc = navigator.plugins["Shockwave Flash"].description;
    if (desc.indexOf(".") != -1)
    desc = desc.substring(desc.indexOf(".") - 1);
    if (desc.charAt(0) >= '4' && desc.charAt(0) <= '9')
    document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,30,0" width="342" height="111"><param name=movie value="images/flash/logo.swf"><param name=quality value=high><param name="salign" value="tl"><param name="menu" value="0"><embed src="images/flash/logo.swf" quality=high pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="342" height="111" salign="tl" menu="0"></embed></object>');
    }
    else if (navigator.appName == "Netscape"){
    document.write('<img src="images/logo_big.gif" width="342" height="111">');
    }
    // -->
    </SCRIPT>

    <!--For Explorer-->
    <SCRIPT LANGUAGE=VBScript>
    Private i, x, MM_FlashControlVersion
    On Error Resume Next
    x = null
    MM_FlashControlVersion = 0
    var Flashmode
    FlashMode = False
    For i = 5 To 1 Step -1
    Set x = CreateObject("ShockwaveFlash.ShockwaveFlash." & i)
    MM_FlashControlInstalled = IsObject(x)
    If MM_FlashControlInstalled Then
    MM_FlashControlVersion = CStr(i)
    Exit For
    End If
    Next
    FlashMode = (MM_FlashControlVersion >= 5)
    If FlashMode = True Then
    document.write "<object classid=""clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"" codebase=""http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,30,0"" width=""342"" height=""111""><param name=movie value=""images/flash/logo.swf?""><param name=quality value=high><param name=""salign"" value=""tl""><param name=""menu"" value=""0""><embed src=""images/flash/logo.swf"" quality=high pluginspage=""http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"" type=""application/x-shockwave-flash"" width=""342"" height=""111"" salign=""tl"" menu=""0""></embed></object>"
    Else
    document.write "<img src=""images/logo_big.gif"" width=""342"" height=""111"">"
    End If
    </SCRIPT>
    I have two tickets to the Crows, sweet.

  6. #6
    SitePoint Member
    Join Date
    Sep 2001
    Location
    London, UK
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    sweeet

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

  8. #8
    SitePoint Wizard creole's Avatar
    Join Date
    Oct 2000
    Location
    Nashvegas Baby!
    Posts
    7,845
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Nope...not only does it detect Flash in general but it detects which version you have.

    It goes something like this:

    frame1 contains an action only available to Flash 5. If the browser has a plugin that understand that action then it goes to page 5.

    frame2 contains an action only available to Flash 4. If the browser has a plugin that understand that action then it goes to page 4.

    and so on. In the background is a META refresh set for like 10 seconds. The detection file is like 1k so it takes no time at all to load and run. If the user has no Flash after all of the above, then the META takes them to the "no flash" page.
    Adobe Certified Coldfusion MX 7 Developer
    Adobe Certified Advanced Coldfusion MX Developer
    My Blog (new) | My Family | My Freelance | My Recipes


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
  •