Guest User

Untitled

a guest
May 20th, 2018
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.78 KB | None | 0 0
  1. <script>
  2. var p;
  3. try {
  4. p = new ActiveXObject('AcroExch.Document');
  5. }
  6. catch (e) {
  7. // active x object could not be created
  8. document.write('doesnt look like the PDF plugin is installed...');
  9. }
  10. if (p) {
  11. document.write('does look like the pdf plugin is installed!');
  12. }
  13. </script>
  14.  
  15. function hasPdfPlugin() {
  16. //detect in mimeTypes array
  17. if (navigator.mimeTypes != null && navigator.mimeTypes.length > 0) {
  18. for (i = 0; i < navigator.mimeTypes.length; i++) {
  19. var mtype = navigator.mimeTypes[i];
  20. if(mtype.type == "application/pdf" && mtype.enabledPlugin)
  21. return true;
  22. }
  23. }
  24.  
  25. //detect in plugins array
  26. if (navigator.plugins != null && navigator.plugins.length > 0) {
  27. for (i = 0; i < navigator.plugins.length; i++) {
  28. var plugin = navigator.plugins[i];
  29. if (plugin.name.indexOf("Adobe Acrobat") > -1
  30. || plugin.name.indexOf("Adobe Reader") > -1) {
  31. return true;
  32. }
  33.  
  34. }
  35. }
  36. // detect IE plugin
  37. if (window.ActiveXObject) {
  38. // check for presence of newer object
  39. try {
  40. var oAcro7 = new ActiveXObject('AcroPDF.PDF.1');
  41. if (oAcro7) {
  42. return true;
  43. }
  44. } catch (e) {
  45. }
  46.  
  47. // iterate through version and attempt to create object
  48. for (x = 1; x < 10; x++) {
  49. try {
  50. var oAcro = eval("new ActiveXObject('PDF.PdfCtrl." + x + "');");
  51. if (oAcro) {
  52. return true;
  53. }
  54. } catch (e) {
  55. }
  56. }
  57.  
  58. // check if you can create a generic acrobat document
  59. try {
  60. var p = new ActiveXObject('AcroExch.Document');
  61. if (p) {
  62. return true;
  63. }
  64. } catch (e) {
  65. }
  66.  
  67. }
  68.  
  69. // Can't detect in all other cases
  70. return false;
  71. }
  72.  
  73. var adobePdfObject = new ActiveXObject("theAdobePdfCOMObject");
Add Comment
Please, Sign In to add comment