我不希望用户在找不到自定义插件时在Firefox上看到“安装缺失的插件”。如何禁用此功能?
<object height="0" width="0" id="mycustomPlugin" type="application/x-vnd-puppyt"></object>
答案 0 :(得分:0)
执行此操作的一种方法 - 可能还有其他方法 - 是在创建对象标记之前检查它是否在navigator.plugins数组中列出。像这样的东西(一些示例代码从最近的项目中剪切和粘贴):
function createVncServer(id) {
console.log(navigator.userAgent);
var vncDiv = document.getElementById("vncDiv");
if (navigator.userAgent.indexOf("MSIE") > -1) {
vncDiv.innerHTML = "<object id='" + id + "' classid='CLSID:42832F4C-3480-4450-A6B5-156B2EFC408F' codebase='http://localhost:51150/Resources/WinVncCtlInstaller.CAB' />";
}
else {
// On Mozilla browsers, check to make sure the plugin is installed before we try to instantiate it, to avoid the weird "plugins required" message.
var pluginInstalled = false;
for (var i = 0; i < navigator.plugins.length; i++) {
console.log(navigator.plugins[i].name);
if (navigator.plugins[i].name == 'Alanta Remote Desktop Server') {
pluginInstalled = true;
}
}
if (pluginInstalled) {
vncDiv.innerHTML = "<object id='" + id + "' type='application/x-alanta-vnc' />";
}
else {
promptForDownload();
return null;
}
}
var vncServer = document.getElementById(id);
try {
if (vncServer.Port > 0) {
clearDownloadPrompt();
return vncServer;
}
else {
promptForDownload();
}
}
catch (ex) {
promptForDownload();
}
}