Created
October 27, 2012 10:10
-
-
Save meglio/3963951 to your computer and use it in GitHub Desktop.
JQuery PDF support detection
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Check for PDF support | |
* Based on http://downloads.beninzambia.com/blog/acrobat_detection.js.txt | |
*/ | |
$.support.pdf = (function() { | |
try { | |
// IE | |
if(!$.support.cssFloat) { | |
var control = null; | |
// | |
// load the activeX control | |
// | |
try { | |
// AcroPDF.PDF is used by version 7 and later | |
control = new ActiveXObject('AcroPDF.PDF'); | |
} | |
catch (e){} | |
if (!control) { | |
try { | |
// PDF.PdfCtrl is used by version 6 and earlier | |
control = new ActiveXObject('PDF.PdfCtrl'); | |
} | |
catch (e) {} | |
} | |
return control ? true : false; | |
} else if(navigator.plugins != null) { | |
for(var n in navigator.plugins) { | |
if (n == 'Adobe Acrobat') { | |
return true; | |
} | |
if (navigator.plugins[n].name && (navigator.plugins[n].name == 'Adobe Acrobat' || navigator.plugins[n].name == 'Chrome PDF Viewer')) { | |
return true; | |
} | |
} | |
} | |
} | |
catch(e){} | |
return false; | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Forked from mrXCray