How to detect if pdf.js is *default* reader in firefox

旧街凉风 提交于 2019-12-19 20:48:23

问题


Since Firefox 19, there is an internal default PDF reader "pdf.js". How can I detect whether this is the reader by default?


回答1:


This might be what you are looking for...

http://www.pinlady.net/PluginDetect/PDFjs/




回答2:


This will test for it. I can't get to the other link due to corporate firewall. Dunno what it says. Maybe its the same.

FIDDLE HERE

<iframe src="some.pdf" id="iframe" name="iframe"></iframe>

.

// FireFox test for PDFJS to display PDFs. Works in 20 & 21.
// If you don't test for the browser ...
//    IE says PDFJS is there. It isn't.
//    Chrome hangs on the fiddle
//    Safari for Windows says PDFJS isn't there
$(window).load(function() {

  var userAgent = navigator ? navigator.userAgent.toLowerCase() : "other";
  if(userAgent.indexOf("firefox") > -1) {

    var $iframe = $("#iframe");
    var $innerDiv;
    try {
      $innerDiv = $iframe.contents().find('div');
      alert("PDFJS not loaded");
    } catch (e) { 
      alert("PDFJS loaded");
    }
  } else {
      alert("Not running in FireFox - no PDFJS available");
  }
});


来源:https://stackoverflow.com/questions/16187902/how-to-detect-if-pdf-js-is-default-reader-in-firefox

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!