Forum de discussion
Forum « Programmation Javascript » (archives)
Re: detecter un plugin sous internet explorer
Envoyé: 27 juillet 2004, 9h24 par Oznog
J'oubliais, de façon générale on utilise le Javascript pour générer du VBScript, ça évite des bogue. Et tu peux aussi ajouter un test pour t'assurer de la compatibilité du moteur VBScript (detectableWithVB).
Exemple avec QuickTime produit par Apple (http://developer.apple.com/internet/webcontent/examples/detectplugins_source.html) :
<script language="JavaScript">
if ((navigator.userAgent.indexOf('MSIE') != -1) && (navigator.userAgent.indexOf('Win') != -1)) {
document.writeln('<script language="VBscript">');
document.writeln('\'do a one-time test for a version of VBScript that can handle this code');
document.writeln('detectableWithVB = False');
document.writeln('If ScriptEngineMajorVersion >= 2 then');
document.writeln(' detectableWithVB = True');
document.writeln('End If');
document.writeln('\'this next function will detect most plugins');
document.writeln('Function detectActiveXControl(activeXControlName)');
document.writeln(' on error resume next');
document.writeln(' detectActiveXControl = False');
document.writeln(' If detectableWithVB Then');
document.writeln(' detectActiveXControl = IsObject(CreateObject(activeXControlName))');
document.writeln(' End If');
document.writeln('End Function');
document.writeln('\'and the following function handles QuickTime');
document.writeln('Function detectQuickTimeActiveXControl()');
document.writeln(' on error resume next');
document.writeln(' detectQuickTimeActiveXControl = False');
document.writeln(' If detectableWithVB Then');
document.writeln(' detectQuickTimeActiveXControl = False');
document.writeln(' hasQuickTimeChecker = false');
document.writeln(' Set hasQuickTimeChecker = CreateObject("QuickTimeCheckObject.QuickTimeCheck.1")');
document.writeln(' If IsObject(hasQuickTimeChecker) Then');
document.writeln(' If hasQuickTimeChecker.IsQuickTimeAvailable(0) Then ');
document.writeln(' detectQuickTimeActiveXControl = True');
document.writeln(' End If');
document.writeln(' End If');
document.writeln(' End If');
document.writeln('End Function');
document.writeln('</scr' + 'ipt>');
}
// -->
</script>
J'imagine que la solution complète devrait être sur "DjVu" (http://www.djvuzone.org/support/index.html)!
Ciao
Oznog
Réponses
|