Skip to content

Instantly share code, notes, and snippets.

@meglio
Created October 27, 2012 10:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save meglio/3963951 to your computer and use it in GitHub Desktop.
Save meglio/3963951 to your computer and use it in GitHub Desktop.
JQuery PDF support detection
/*
* 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;
})();
@meglio
Copy link
Author

meglio commented Oct 27, 2012

Forked from mrXCray

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment