The Google Chrome block Java plugin until you explicitly allow it to run. https://www.google.com/support/chrome/bin/answer.py?answer=1247383&hl=en-US
How can I detect in javascript if Chrome block it?
The Google Chrome block Java plugin until you explicitly allow it to run. https://www.google.com/support/chrome/bin/answer.py?answer=1247383&hl=en-US
How can I detect in javascript if Chrome block it?
It's not only Chrome employing click-to-play features - Firefox (Java made click-to-play via blocklist), Opera (their Turbo mode makes all plugins click-to-play), ... and there are also Add-ons/Extensions that prevent plugins from running automatically.
None of those allow you do find out about plugins being click-to-play from content scripts. So ideally you address the problem in a more general way.
You can differentiate between the plugin not being installed (see navigator.plugins
) and other cases by either
... and assume "failed to load or got blocked" based on that. There is a best-practices page on MDN for this.
That distinction should usually be good enough, check e.g. how SoundCloud handles plugins being click-to-play.
Answer edited 2013.03.15 to improve accuracy of information
A list of supported plugins is available as an array in the navigator
object:
navigator.plugins
This API is non-standard, but all modern browsers implement it. Internet Explorer support goes back to at least IE7, but it's not available in old versions of Opera.
navigator.plugins
has this basic structure:
PluginArray [
...
Plugin {
description: "Java Plug-In 2 for NPAPI Browsers"
filename: "JavaAppletPlugin.plugin"
length: 17
name: "Java Plug-In 2 for NPAPI Browsers"
},
...
]
Here's a function that loops over navigator.plugins
and checks the name
property for a given string. It returns true
or false
if found.
function pluginEnabled(name) {
var plugins = navigator.plugins,
i = plugins.length,
regExp = new RegExp(name, 'i');
while (i--) {
if (regExp.test(plugins[i].name)) return true;
}
return false;
}
Use it like so (case insensitive):
pluginEnabled('java');
pluginEnabled('flash');