Click here to Skip to main content
15,032,755 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I need to detect whether flash is installed in users system using javascript.

Please help me..

I need to detect in all browsers( Especially IE)
Posted

Hi All,

Steps to follow:

Step 1: Download the External JavaScipt from below link.

Step 2: Create JSP in eclipse and import the external JS.
Steps to import external JS to Eclipse project:
Right Click on your project -> New -> JavaScript Source File -> Click :Advanced -> Select :Link to File in Filesystem -> your Exteranl JS folder and click to finish.

Step 3: Copy the below two Java scripts tags and paste it inside your body tag.

Step 4: Call the check() method in your onclick or onsubmit.
example : <input type="button" value="Submit" onclick="check()" />

***********************************************************************************
The above piece of code will not function but below code will work on all scenarios even the Flash plugin is disabled. It will alert you plugin is disabled or enabled, installed or not installed and redirect you to flash site to install the flash player.

NOTE : My code need a predefined(external) JavaScript. This will work on all the browsers IE,Chrome,Firefox,safari,Netscape,opera.

you may use the below URL and download the predefined(external) JavaScript:

https://drive.google.com/file/d/0BxPiAFM0fZYkZ1p4Yi1hVUUzaWM/view?usp=sharing

############Below script is to detect the browser#############

C#
<SCRIPT LANGUAGE="javascript">
function browserName(){
    var nAgt = navigator.userAgent;
    var browserName  = navigator.appName;
    var fullVersion  = ''+parseFloat(navigator.appVersion);
    var majorVersion = parseInt(navigator.appVersion,10);
    var nameOffset,verOffset,ix;

    // In Opera, the true version is after "Opera" or after "Version"
    if (verOffset=!!window.opera || navigator.userAgent.indexOf(' OPR/') >= 0)
    {
            browserName = "Opera";
            fullVersion = nAgt.substring(verOffset+6);
            if ((verOffset=nAgt.indexOf("Version"))!=-1)
                fullVersion = nAgt.substring(verOffset+8);
    }

    // In MSIE, the true version is after "MSIE" in userAgent
    else if ((verOffset=nAgt.indexOf("MSIE"))!=-1)
    {
            browserName = "Microsoft Internet Explorer";
            fullVersion = nAgt.substring(verOffset+5);
    }

    // In Chrome, the true version is after "Chrome"
    else if ((verOffset=nAgt.indexOf("Chrome"))!=-1)
    {
            browserName = "Chrome";
            fullVersion = nAgt.substring(verOffset+7);
    }

    // In Safari, the true version is after "Safari" or after "Version"
    else if ((verOffset=nAgt.indexOf("Safari"))!=-1)
    {
            browserName = "Safari";
            fullVersion = nAgt.substring(verOffset+7);
            if ((verOffset=nAgt.indexOf("Version"))!=-1)
                fullVersion = nAgt.substring(verOffset+8);
    }

    // In Firefox, the true version is after "Firefox"
    else if ((verOffset=nAgt.indexOf("Firefox"))!=-1)
    {
            browserName = "Firefox";
            fullVersion = nAgt.substring(verOffset+8);
    }

    // In most other browsers, "name/version" is at the end of userAgent
    else if ( (nameOffset=nAgt.lastIndexOf(' ')+1) < (verOffset=nAgt.lastIndexOf('/')) )
    {
            browserName = nAgt.substring(nameOffset,verOffset);
            fullVersion = nAgt.substring(verOffset+1);
            if (browserName.toLowerCase()==browserName.toUpperCase())
        {
                browserName = navigator.appName;
        }
    }

    // trim the fullVersion string at semicolon/space if present
    if ((ix=fullVersion.indexOf(";"))!=-1)
            fullVersion=fullVersion.substring(0,ix);
    if ((ix=fullVersion.indexOf(" "))!=-1)
            fullVersion=fullVersion.substring(0,ix);

    majorVersion = parseInt(''+fullVersion,10);

    if (isNaN(majorVersion))
    {
            fullVersion  = ''+parseFloat(navigator.appVersion);
            majorVersion = parseInt(navigator.appVersion,10);
    }

    return browserName.substring(0, 6).toLowerCase();
}
</SCRIPT>




*********below code detect the flash player is (installed or not installed) and (Enabled or disabled)*********

<script type="text/javascript" src="PluginDetect.js"></script>
<script type="text/javascript">
function check()
{

if(browserName()=="chrome")
{
PluginDetect.getVersion(".");
var version = PluginDetect.getVersion('Flash', true);
if(version==null)
{

window.alert("Sorry, Flash Player is either not installed or not enabled.");
}
else
{
var maxversion = parseInt(version.substring(0, 1));

if(maxversion<=0)
{
window.alert("Sorry, Flash Player is not installed or not enabled.");
window.location="https://get.adobe.com/flashplayer/";
}

}
}
else
{
PluginDetect.getVersion(".");
var version = PluginDetect.getVersion('Flash', true);

if(version==null)
{

window.alert("Sorry, Flash Player is either not installed or not enabled.");
window.location="https://get.adobe.com/flashplayer/";
}
else
{

var maxversion = parseInt(version.substring(0, 1));
if(maxversion<=0)
{
window.alert("you dont have a flash player");
window.location="https://get.adobe.com/flashplayer/";
}
}
}


}
</script>
******************* END ***************************
   
v19
Comments
Kornfeld Eliyahu Peter 13-Jan-15 5:58am
   
CP is not for your personal benefits! So please do not use it to gain job, by posting your contact info. If someone will contact you via comments you will be notified...
hi first check this link..

SWFObject

JavaScript
var hasFlash = false;
try {
  var fo = new ActiveXObject('ShockwaveFlash.ShockwaveFlash');
  if(fo) hasFlash = true;
}catch(e){
  if(navigator.mimeTypes ["application/x-shockwave-flash"] != undefined) hasFlash = true;
}
   

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