|
Detectando plugins com JavaScript |
|
|
|
|
A saída se resume ao seguinte. Inclua a referência à biblioteca criada pelo Eric Gerds na página, dessa maneira:
<script src="http://www.pinlady.net/PluginDetect/PluginDetectAll.js"></script>
Em seguida crie seu próprio script fazendo uso da biblioteca do cara. Se preferir, pode usar o código que eu usei como modelo. Pra enfeitar mais ainda, incluí também as logos dos plugins em formato gif, coloridas e preto-e-brancas, pra mostrar quando o Plugin existe ou não existe.
var plugins = ['QuickTime','Flash','Shockwave', 'WindowsMediaPlayer',
'Silverlight','VLC'];
function checkPlugin(name) {
img = document.createElement('img');
if( PluginDetect.isMinVersion(name, '0') >= 0 ) {
img.src = '/scripts/plugindetect-0.1/icons/'+name+'.jpg';
img.alt = name + ' - ' + PluginDetect.getVersion(name);
}
else {
img.src = '/scripts/plugindetect-0.1/icons/'+name+'-bw.jpg';
img.alt = name + ' - ' + "not installed";
}
div = document.getElementById('PluginsCheckResult');
div.appendChild(img);
}
for ( p in plugins ) {
checkPlugin(plugins[p]);
}
|