SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Thread: Detectin Flash

  1. #1
    SitePoint Zealot Drew630's Avatar
    Join Date
    Nov 2001
    Location
    Maryland
    Posts
    175
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Detectin Flash

    I did a search on the forums and I was only able to find threads that suggested using JS for detecting plugins, but no actual code to help me along. So, I figured I'd throw out the question here to see if anyone has any ideas.

    I need to detect for FLash in a website I'm working on. Is there any good scripts out there to do this?

    Drew
    ~Drew

    There Is No Greater Joy Than Soaring High On The Wings Of Your Dreams, Except Maybe The Joy Of Watching A Dreamer Who Has Nowhere To Land But In The Ocean Of Reality.

  2. #2
    Santos L Halper Zenith's Avatar
    Join Date
    May 2002
    Location
    Finland
    Posts
    641
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Google still exists:
    http://www.google.com/search?hl=en&i...t+flash+plugin

    Just check how it's done on those sites, with quick look it seems like they're all using pretty much same JS-function.

    -Z-

  3. #3
    SitePoint Addict
    Join Date
    May 2000
    Posts
    313
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

  4. #4
    SitePoint Enthusiast
    Join Date
    Nov 2002
    Posts
    51
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    browser = new Object();
    browser.detect = function(){
      this.agent = navigator.userAgent.toLowerCase();
      this.win = this.agent.indexOf("win")!=-1;
      this.win32 = this.win && this.agent.indexOf("16bit")==-1;
      this.iex = document.all ?true:false;
    };
    browser.detect();
    
    flash = new Object();
    flash.detect = function(){
      this.currentVersion = 8;// The current Flash version or greater
      this.versionInstalled = 0;
      if(navigator.plugins != null && navigator.plugins.length > 0){
        var plugin = navigator.plugins["Shockwave Flash"];
        if(typeof plugin == "object"){
          for(i=3; i<= this.currentVersion; i++){
            if(plugin.description.indexOf(i+".") != -1){
              this.versionInstalled = i;
            }
          }
        }else if(navigator.plugins["Shockwave Flash 2.0"]){
          this.versionInstalled = 2;
        }
      }else if(browser.iex && browser.win32){
        document.write('<'+'script language="VBScript"'+'> \n');
          document.write('set FlashObj = Nothing \n');
          document.write('on error resume next \n');
          document.write('For i = '+this.currentVersion+' to 3 step -1 \n');
            document.write('set FlashObj = CreateObject("ShockwaveFlash.ShockwaveFlash." & i) \n');
            document.write('If (Not(FlashObj is Nothing)) Then \n');
              document.write('flash.versionInstalled = i \n');
              document.write('Exit For \n');
            document.write('End If \n');
          document.write('Next \n');
        document.write('<'+'\/script'+'> \n');
    
      }else if(xBrowser.agent.indexOf("webtv/2.5") != -1){
        this.versionInstalled = 3;
      }else if(xBrowser.agent.indexOf("webtv") != -1){
        this.versionInstalled = 2;
      }else{
        this.versionInstalled = -1;
      }
    };
    flash.redirect = function(requiredVersion, upgradeFlash, noFlash, failedCheck){
      if(this.versionInstalled < requiredVersion){
        var url;
        if(this.versionInstalled == -1){
          if(!failedCheck) return;
          url = failedCheck;
        }else if(this.versionInstalled == 0){
          url = noFlash;
        }else{
          url = upgradeFlash;
        }
        window.location.href = url;
      }
    };
    flash.detect();
    
    // --------------------------------------------------
    // Example/Usage:
    
    // Argument Description for "flash.redirect"
    /* --------------------------------------------------
    
    1. The minimum Flash version required.
    
    2. The HTML page the user is redirected to if they 
       have the Flash plug-in installed, but it does not 
       meet the version requirements.
    
    3. The HTML page the user is redirected to if there 
       is no Flash plug-in installed in their browser.
    
    4. The HTML page the user is redirected to if their 
       browser is not capable of being checked for the 
       Flash plug-in (MacIE4). This argument is 
       optional. If omitted and the browser cannot be 
       checked, the script will assume they have the 
       Flash plug-in.
    
    -------------------------------------------------- */
    flash.redirect (5, "upgrade_flash.html", "no_flash.html", "failed_check.html");
    travis

  5. #5
    SitePoint Zealot Drew630's Avatar
    Join Date
    Nov 2001
    Location
    Maryland
    Posts
    175
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Wow. thanks guys, I got it to work.

    Drew
    ~Drew

    There Is No Greater Joy Than Soaring High On The Wings Of Your Dreams, Except Maybe The Joy Of Watching A Dreamer Who Has Nowhere To Land But In The Ocean Of Reality.


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
  •