码迷,mamicode.com
首页 > Web开发 > 详细

js判断是否安装pdf播放器

时间:2015-09-13 17:10:32      阅读:206      评论:0      收藏:0      [点我收藏+]

标签:

function isPDFPluginInstall() {
if (!isIE()) { //ie 浏览器 和 非ie浏览器支持
// not ie
if (navigator.plugins && navigator.plugins.length) // / Adobe Reader | Adobe PDF | Acrobat | Chrome PDF Viewer
for (var i = 0 ; i < navigator.plugins.length; i++) {
var plugin = navigator.plugins[i].name;
console.log(plugin);
if (plugin == ‘Adobe Reader‘ || plugin == ‘Adobe PDF‘ || plugin == ‘Acrobat‘ || plugin == ‘Chrome PDF Viewer‘) return true;
}
return false;
} else {
// ie
var isInstalled = false;
var version = null;

var control = null;
try {
control = new ActiveXObject(‘AcroPDF.PDF‘);
} catch (e) {
alert(e);
}
if (!control) {
try {
control = new ActiveXObject(‘PDF.PdfCtrl‘);
} catch (e) {
}
}
if (!control) {
try {
control = new ActiveXObject(‘Adobe Acrobat‘);
} catch (e) {
}
}

if (!control) {
try {
control = new ActiveXObject(‘Adobe PDF Plug-in‘);
} catch (e) {
}
}
if (control) {
isInstalled = true;
version = control.GetVersions().split(‘,‘);
version = version[0].split(‘=‘);
version = parseFloat(version[1]);
return isInstalled;
}
}
}

function isIE() { //ie 支持到ie11
if (!!window.ActiveXObject || "ActiveXObject" in window)
return true;
else
return false;
}

js判断是否安装pdf播放器

标签:

原文地址:http://www.cnblogs.com/liucyi/p/4805147.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!