Internet explorer 检测MsIE中的Pdf读取器

Internet explorer 检测MsIE中的Pdf读取器,internet-explorer,detection,pdf-viewer,Internet Explorer,Detection,Pdf Viewer,我使用IFrame在单击该IFrame中的链接时查看Pdf文档。但是,在没有读卡器的机器上,链接将提示下载。有没有一种方法,当检测到没有读卡器时,相同的链接可以提示用户下载读卡器?我想我在什么地方见过这个。谢谢 在JavaScript中,您可以执行以下操作: var adobePdfObject = new ActiveXObject("theAdobePdfCOMObject"); 然后捕获一个失败错误或adobePdfObject的返回值?,这有助于检测Acrobat的存在。这在IE中适用

我使用IFrame在单击该IFrame中的链接时查看Pdf文档。但是,在没有读卡器的机器上,链接将提示下载。有没有一种方法,当检测到没有读卡器时,相同的链接可以提示用户下载读卡器?我想我在什么地方见过这个。谢谢

在JavaScript中,您可以执行以下操作:

var adobePdfObject = new ActiveXObject("theAdobePdfCOMObject");

然后捕获一个失败错误或adobePdfObject的返回值?

,这有助于检测Acrobat的存在。

这在IE中适用:

<script>
var p;
try {
p = new ActiveXObject('AcroExch.Document');
}
catch (e) {
// active x object could not be created
document.write('doesnt look like the PDF plugin is installed...');
}
if (p) {
    document.write('does look like the pdf plugin is installed!');
}
</script>

var-p;
试一试{
p=新的ActiveXObject(“AcroExch.Document”);
}
捕获(e){
//无法创建活动的x对象
write('看起来PDF插件没有安装…');
}
如果(p){
write('看起来像是安装了pdf插件!');
}

…但修改后删除了“endif”

我知道这个问题已经得到了回答,但我最近不得不构建一个功能,检测不同浏览器中是否存在PDF插件。这就是我得到的。希望能有帮助

function hasPdfPlugin() {   
//detect in mimeTypes array
if (navigator.mimeTypes != null && navigator.mimeTypes.length > 0) {        
    for (i = 0; i < navigator.mimeTypes.length; i++) {
        var mtype = navigator.mimeTypes[i];
        if(mtype.type == "application/pdf" && mtype.enabledPlugin)
            return true;
    }
}

//detect in plugins array
if (navigator.plugins != null && navigator.plugins.length > 0) {
    for (i = 0; i < navigator.plugins.length; i++) {
        var plugin = navigator.plugins[i];
        if (plugin.name.indexOf("Adobe Acrobat") > -1
                || plugin.name.indexOf("Adobe Reader") > -1) {
            return true;
        }

    }
} 
// detect IE plugin
if (window.ActiveXObject) {
    // check for presence of newer object       
    try {
        var oAcro7 = new ActiveXObject('AcroPDF.PDF.1');
        if (oAcro7) {
            return true;
        }
    } catch (e) {
    }

    // iterate through version and attempt to create object 
    for (x = 1; x < 10; x++) {
        try {
            var oAcro = eval("new ActiveXObject('PDF.PdfCtrl." + x + "');");
            if (oAcro) {
                return true;
            }
        } catch (e) {
        }
    }

    // check if you can create a generic acrobat document
    try {
        var p = new ActiveXObject('AcroExch.Document');
        if (p) {
            return true;
        }
    } catch (e) {
    }

}

// Can't detect in all other cases
return false;
}
函数hasPdfPlugin(){
//在mimeTypes数组中检测
如果(navigator.mimeTypes!=null&&navigator.mimeTypes.length>0){
对于(i=0;i0){
对于(i=0;i-1
||plugin.name.indexOf(“Adobe Reader”)>-1){
返回true;
}
}
} 
//检测IE插件
if(window.ActiveXObject){
//检查是否存在较新的对象
试一试{
var oAcro7=新的ActiveXObject('AcroPDF.PDF.1');
如果(oAcro7){
返回true;
}
}捕获(e){
}
//迭代版本并尝试创建对象
对于(x=1;x<10;x++){
试一试{
var-oAcro=eval(“新ActiveXObject('PDF.PdfCtrl.+x+”);”;
国际单项体育联合会(oAcro){
返回true;
}
}捕获(e){
}
}
//检查是否可以创建通用acrobat文档
试一试{
var p=新的ActiveXObject('AcroExch.Document');
如果(p){
返回true;
}
}捕获(e){
}
}
//无法在所有其他情况下检测到
返回false;
}

您可能还必须考虑到许多用户(包括我自己)禁用与PDF阅读器的浏览器集成。在MsIE 7中,如何选择禁用与PDF阅读器的浏览器集成?+1用于禁用恼人的浏览器内PDF阅读器!如果您想禁用它,假设您使用的是adobe reader,它位于adobe reader首选项中。请注意,有些浏览器还提供禁用此功能的功能,但不确定IE是否提供此功能。请不要这样做。让用户决定用什么打开PDF。这似乎是最全面的方法,但我仍在努力让它工作。任何填鸭式喂食都将不胜感激。我对这个问题很感兴趣,你能提供一些关于这个问题的信息吗?我觉得只是提供一个没有解释的链接总比没有好,但是仍然有一些地方需要改进。我已经在几个网站上实现了这些脚本,没有任何问题。我认为,当所有相关的详细信息都可以在网站上找到时,没有必要在这里复制网站上的信息。尽管MsIE的activeX标记非常粗糙,但这似乎是有效的。是否存在跨浏览器jquery检测?