Display PDF using plugin : PlugIn : Development : JavaScript DHTML examples (example source code) Organized by topic

JavaScript DHTML
C++
PHP
JavaScript DHTML Home »  Development   » [  PlugIn  ]   
 



Display PDF using plugin

Please note that some example is only working under IE or Firefox.

/*
Javascript Essentials
by Jason J. Manger

Publisher: Mcgraw-Hill Osborne Media; 

ISBN: 0078822343
*/

<!--
  Program 12-5
  Author note: The file 'jsess.pdf' does not exist, and is
  purely a hypothetical file that is used in this particular 
  program as an example of a sample plug-in media file.
-->
<html>
<head>
<script language="JavaScript">
<!--
function findPlugin(ext) {
  var thisExt, findExt;
  for (var n=0; n < navigator.plugins.length; n++) {
      for (var m=0; m < navigator.plugins[n].length; m++) {
          thisExt = navigator.plugins[n][m].description.toLowerCase();
          findExt = thisExt.substring(0, thisExt.indexOf(" "));
          if (findExt == ext)
             return(true);
      }
  }
  return(false);
}
  
// See if the user has a PDF compatible plug-in, i.e., Amber,
// if this exists, dynamically create the HTML to invoke the
// plug-in application:

if (findPlugin("pdf")) {
   // The user can view the PDF file, so embed one within the
   // current page
   document.open();
   document.write("<embed src='jsess.pdf' width='100%'>");
   document.close();
}
else {
   // The user cannot view the PDF file, so show the user a 
   // HTML-only version of the file instead:
   location = "essjava.htm";
}
//-->
</script>
</head>
</html>



           
       
Related examples in the same category
1.   Listing Plug-In Properties
2.  Synchronizing Two Plug-Ins
3.   Accessing a Plug-In
4.  Determining Whether the LiveVideo Plug-In Is Installed
5.  The About Plug-Ins Script
6.  Displaying Plug-In Information
7.  Find pluin for Midi
8.  Scan through each plug-in by provided parameters
9.  Displaying a List of Navigator Plug-Ins
10.  Properties of the Plugin Object
























Home| Contact Us
Copyright 2003 - 04 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.