Detectar plugins en Explorer con Javascript
Escrito por J.F. el Viernes, 16 de Mayo del 2008 a las 14:24
Cortesía de Anieto, un útil script que utiliza window.ActiveXObject() comprobar en Internet Explorer que plugins se encuentran instalados, y cuales no.
-
var plugins = {
-
hasAcrobat:function() {
-
if (!window.ActiveXObject) return false;
-
try { if (new ActiveXObject('AcroPDF.PDF')) return true;}
-
catch (e) {}
-
try { if (new ActiveXObject('PDF.PdfCtrl')) return true;}
-
catch (e) {}
-
return false;
-
},
-
hasFlash: function() {
-
if (!window.ActiveXObject) return false;
-
try {if (new ActiveXObject('ShockwaveFlash.ShockwaveFlash')) return true;}
-
catch (e) { return false;}
-
},
-
hasJava: function() {
-
return (!navigator.javaEnabled());
-
},
-
hasQuickTime: function() {
-
if (!window.ActiveXObject) return false;
-
try { if (new ActiveXObject('QuickTime.QuickTime')) return true;}
-
catch (e) {}
-
try {if(new ActiveXObject('QuickTimeCheckObject.QuickTimeCheck')) return true;}
-
catch (e) {};
-
return false;
-
},
-
hasRealPlayer: function() {
-
if (!window.ActiveXObject) return false;
-
var definedControls = [
-
'rmocx.RealPlayer G2 Control',
-
'rmocx.RealPlayer G2 Control.1',
-
'RealPlayer.RealPlayer(tm) ActiveX Control (32-bit)',
-
'RealVideo.RealVideo(tm) ActiveX Control (32-bit)',
-
'RealPlayer'
-
];
-
for (var i = 0; i <definedControls.length; i++) {
-
try {if(new ActiveXObject(definedControls[i])) return true;}
-
catch (e) {continue;}
-
}
-
return false;
-
},
-
hasShockwave: function() {
-
if (!window.ActiveXObject) return false;
-
try {if(new ActiveXObject(’SWCtl.SWCtl’)) return true;}
-
catch (e) {return false;}
-
},
-
hasWMP: function() {
-
if (!window.ActiveXObject) return false;
-
try {if(new ActiveXObject(’WMPlayer.OCX’)) return true;}
-
catch (e) { return false;}
-
}
-
}
Modo de empleo
-
if (plugins.hasFlash()) {
-
//Código en caso de tener flash instalado
-
} else {
-
//Código en caso de notener flash instalado
-
}
Enlace: | Autor
Categoria: Javascript
- Añadir este post a
- Del.icio.us -
- Meneame -
- Digg -
- Webeame
Entradas relacionadas
Deja un comentario
