SwfObject - Detect flash without the "Allow to run..." firefox message
Asked Answered
G

2

8

I've been using swfobject in one of my projects in order to detect if the end-user has a version of Flash installed. The problem is with Firefox, because it shows the message: "Allow to run Adobe Flash?" and that is something I want to avoid.

It's not about showing alternative content to the end-user, what I want is to only try to detect Flash and if flash is not installed don't show anything, but if flash is installed, then don't show the Allow to run... message in Firefox.

Does anyone know any way to prevent this from happening with SwfObject?

Note: Just by including the next line in the html header:

<script type="text/javascript" src="swfobject.js"></script>

it triggers the Allow to Run message :S

If you think there's a better alternative to swfobject in order to solve this and it's a good multipurpose swf-handler tool, I'm all ears.

Here's an example of the message:

enter image description here

Thanks

Geodetic answered 5/9, 2014 at 2:24 Comment(2)
hasFlash=[].some.call(navigator.plugins, function(p){return p.name=="Shockwave Flash"})Mood
@dandavis, why don't you make that into a full answer? In what context should your code be used?Robbynrobe
S
3

Something like:

var flashInstalled = ((typeof navigator.plugins != "undefined" && typeof navigator.plugins["Shockwave Flash"] == "object") || (window.ActiveXObject && (new ActiveXObject("ShockwaveFlash.ShockwaveFlash")) != false));

Not sure if you need to check all browsers, or just some, so you may be able to remove the activeX checks....

Schweiz answered 20/7, 2016 at 10:34 Comment(0)
T
2

The navigator mimeType represents a plugin object . You can use this to loop through and grab the details of any plugin that is enabled in the browser .

Example :

Calling navigator.mimeTypes will return an array of plugin objects .

FYI: if the user has a plugin disabled then it will not appear in this array..

The easiest logic is to simply search the description for shockwave

var plugins = navigator.mimeTypes;

var i;

    for(i = 0 ; i < plugins.length ; i++){

            var pluginName = plugins[i].description.toLowerCase()

            if(pluginName.indexOf('shockwave') > -1){

                console.log(pluginName + ' : flash in enabled')

                break;
            }

    }

paste this script in any console .

Hope this helps

Trattoria answered 20/7, 2016 at 15:21 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.