Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP VBScript Javascript
Hi everybody,

I am facing problem to detect the flash status(enable/disable) for IE.Though the below code is working fine for mozilla and chrome.I am fed up with IE. Frown | :(
Can anyone please answer by below question and check the code?
1.Is it possible to detect flash status for IE?
2.If yes,what is the drawback in the attached code?
3.Is there any other way to achieve this goal?

Thanks in Advance!!

<pre lang="Javascript">function CheckFlashPlayer()
 
{
 
 var hasFlash = false;
 
 if (navigator.plugins && navigator.plugins.length) //This part is used in Mozilla and Chrome
 
            {
 
                          var plugin = navigator.plugins['Shockwave Flash'];
 
                          if (plugin)
 
                           {
 
                            hasFlash = true;
 
                           }
 
                         
 
                          if (navigator.plugins['Shockwave Flash 2.0'])
 
                           {
 
                            hasFlash = true;
 
                            flashVersion = '2.0.0.11';
 
                           }
 
} 
 
   else if (navigator.mimeTypes && navigator.mimeTypes.length)
 
    {
 
                        var mimeType = navigator.mimeTypes['application/x-shockwave-flash'];
 
                        hasFlash = mimeType && mimeType.enabledPlugin;
 
    }
 
    else 
 
    {
 
                        try 
 
                        {
 
                                    // This Part is for IE 
 
                          var ax = new ActiveXObject('ShockwaveFlash.ShockwaveFlash.7');
 
                          hasFlash = true;                      
 
                        }    
 
       catch (e)
 
        {
 
                                    // Try 6 next, some versions are known to crash with GetVariable calls
 
                                     try 
 
                                     {
 
                                      var ax = new ActiveXObject('ShockwaveFlash.ShockwaveFlash.6');
 
                                      hasFlash = true;
 
                                      
 
                                     } 
 
                                    catch (e)
 
                                     {
 
                                                            try 
 
                                                            {
 
                                                            // For checking default activeX, if all above check fails
 
                                                            var ax = new ActiveXObject('ShockwaveFlash.ShockwaveFlash');
 
                                                              hasFlash = true;
 
                                                         } 
 
                                                            catch (e)
 
                                                             {
 
                                                             hasFlash = false;
 
                                                            }
 
                                     }}}
 
         if(hasFlash)//This part is to set visibility of demo div
 
                        {document.getElementById("divWinFlash").style.display="block"; }
 
}
 
Posted 27-Nov-12 5:59am
Edited 3-Dec-12 22:54pm
v2
Comments
Sergey Alexandrovich Kryukov at 27-Nov-12 11:03am
   
I would advise you to fix the title of the question to avoid confusions: properly explain what do you call "flash"; one could think it's a flash drive or something...
Yes, the question explains it, but some might not even open the page because of wrong title...
--SA
Sugato Pal at 27-Nov-12 11:30am
   
Thanks, i will modify..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sascha Lefévre 485
1 Sergey Alexandrovich Kryukov 325
2 Maciej Los 255
3 Abhinav S 185
4 Peter Leow 110
0 Sergey Alexandrovich Kryukov 6,953
1 OriginalGriff 6,311
2 Maciej Los 2,732
3 Peter Leow 2,694
4 Abhinav S 2,652


Advertise | Privacy | Mobile
Web01 | 2.8.150414.1 | Last Updated 4 Dec 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100