/*
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>
|