[英]Get Adobe Reader version using Javascript
用Javascript获取Adobe Reader版本的最佳方法是什么。
I've modified the code you gave above to work with non-IE browsers. 我已经修改了您上面提供的与非IE浏览器一起使用的代码。
function CheckAdobeVersion() {
var isInstalled = false;
var version = null;
if (window.ActiveXObject) {
var control = null;
try {
// AcroPDF.PDF is used by version 7 and later
control = new ActiveXObject('AcroPDF.PDF');
} catch (e) {
// Do nothing
}
if (!control) {
try {
// PDF.PdfCtrl is used by version 6 and earlier
control = new ActiveXObject('PDF.PdfCtrl');
} catch (e) {
return;
}
}
if (control) {
isInstalled = true;
version = control.GetVersions().split(',');
version = version[0].split('=');
version = parseFloat(version[1]);
return version;
}
} else {
// Changes added in here
var plugins = navigator.plugins;
for(var i = 0; i < plugins.length; i++){
if (plugins[i].name === "Adobe Acrobat"){
version = plugins[i].version;
if(!version) {
version = plugins[i].description.split('"')[1];
}
return parseFloat(version);
}
}
}
}
This uses the navigator.plugins
property to look for Adobe Reader. 这将使用
navigator.plugins
属性查找Adobe Reader。 It works for me with Firefox, Chrome, Safari and Opera, but I've only tested this with version 9 of Reader. 它适用于Firefox,Chrome,Safari和Opera,但我仅在Reader 9版本中对此进行了测试。
See the live version: http://jsfiddle.net/EGbY5/3/ 观看实时版本: http : //jsfiddle.net/EGbY5/3/
I have found this but it only works in Internet Explorer 我已经找到了,但是只能在Internet Explorer中使用
function CheckAdobeVersion() {
var isInstalled = false;
var version = null;
if (window.ActiveXObject) {
var control = null;
try {
// AcroPDF.PDF is used by version 7 and later
control = new ActiveXObject('AcroPDF.PDF');
} catch (e) {
// Do nothing
}
if (!control) {
try {
// PDF.PdfCtrl is used by version 6 and earlier
control = new ActiveXObject('PDF.PdfCtrl');
} catch (e) {
return;
}
}
if (control) {
isInstalled = true;
version = control.GetVersions().split(',');
version = version[0].split('=');
version = parseFloat(version[1]);
return version;
}
} else {
// Check navigator.plugins for "Adobe Acrobat" or "Adobe PDF Plug-in"*
}
}
Any ideas how i could get it to work in Firefox or chrome? 有什么想法可以使它在Firefox或chrome中工作吗?
Sp SP
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.