Open In App
Related Articles

How to detect flash is installed or not using JavaScript ?

Improve Article
Improve
Save Article
Save
Like Article
Like

The task is to detect whether the user has installed Adobe Flash player or not with the help of JavaScript. we’re going to discuss 2 techniques.

Approach:

  • Create a ShockwaveFlash.ShockwaveFlash object.
  • If the instance’s value is true, Flash is installed.
  • If any error occurred, Use navigator.mimetypes property to know whether the flash is installed.

Example 1: This example checks whether the flash player is installed or not. 

html




<h1 style="color:green;">
    GeeksforGeeks
</h1>
  
<p id="GFG_UP">
</p>
  
<button onclick="GFG_Fun()">
    click here
</button>
  
<p id="GFG_DOWN">
</p>
  
<script>
    var el_up = document.getElementById("GFG_UP");
    var el_down = document.getElementById("GFG_DOWN");
      
    el_up.innerHTML = "Click on the button to check"+
            " whether Adobe Flash is installed or not";
      
    var Flash = false;
      
    function GFG_Fun() {
        try {
            Flash =
            Boolean(new ActiveXObject('ShockwaveFlash.ShockwaveFlash'));
        } catch (exception) {
            Flash = ('undefined' != typeof navigator.mimeTypes[
                'application/x-shockwave-flash']);
        }
        el_down.innerHTML = Flash;
    }
</script>


Output:

How to detect flash is installed or not using JavaScript ?

How to detect flash is installed or not using JavaScript ?

Example 2: This example checks the flash player is installed or not. 

html




<h1 style="color:green;">
    GeeksforGeeks
</h1>
  
<p id="GFG_UP">
</p>
  
<button onclick="GFG_Fun()">
    click here
</button>
  
<p id="GFG_DOWN">
</p>
  
<script>
    var el_up = document.getElementById("GFG_UP");
      
    var el_down = document.getElementById("GFG_DOWN");
      
    el_up.innerHTML = "Click on the button to check whether"
            + " Adobe Flash is installed or not";
    var Flash = false;
      
    function GFG_Fun() {
        try {
            var fo =
            new ActiveXObject('ShockwaveFlash.ShockwaveFlash');
              
            if (fo) {
                hasFlash = true;
            }
        } catch (e) {
            if (navigator.mimeTypes && navigator.mimeTypes[
            'application/x-shockwave-flash'] != undefined &&
                navigator.mimeTypes['application/x-shockwave-flash'
                                ].enabledPlugin) {
                hasFlash = true;
            }
        }
        el_down.innerHTML = Flash;
    }
</script>


Output:

How to detect flash is installed or not using JavaScript ?

How to detect flash is installed or not using JavaScript ?


Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!

Last Updated : 19 Jan, 2023
Like Article
Save Article
Similar Reads
Related Tutorials