Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 812
Edenshaw Avatar asked Sep 05 '14 02:09

Edenshaw


2 Answers

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....

like image 197
Stuart Avatar answered Nov 14 '22 06:11

Stuart


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

like image 29
KpTheConstructor Avatar answered Nov 14 '22 06:11

KpTheConstructor