Click here to Skip to main content
15,885,366 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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. :(
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
Updated 3-Dec-12 21:54pm
v2
Comments
Sergey Alexandrovich Kryukov 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 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)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900