The Syntax Breakdown

The script is included in one file, index.html. You’ll find it in your zip file at ch03/index.html. Example 3.1 has the code.

Example 3-1. index.html

 1 <HTML> 2 <HEAD> 3 <TITLE>The Slideshow</TITLE> 4 5 <STYLE TYPE="text/css"> 6 #menuConstraint { height: 800; } 7 </STYLE> 8 9 <SCRIPT LANGUAGE="JavaScript1.2"> 10 <!-- 11 var dWidLyr = 450; 12 var dHgtLyr = 450; 13 var curSlide = 0; 14 var zIdx = -1; 15 var isVis = false; 16 17 var NN = (document.layers ? true : false); 18 var sWidPos = ((NN ? innerWidth : screen.availWidth) / 2) - 19 (dWidLyr / 2); 20 var sHgtPos = ((NN ? innerHeight : screen.availHeight) / 2) - 21 (dHgtLyr / 2); 22 var hideName = (NN ? 'hide' : 'hidden'); 23 var showName = (NN ? 'show' : 'visible'); 24 25 var img = new Array(); 26 var imgOut = new Array(); 27 var imgOver = new Array(); 28 var imgPath = 'images/'; 29 30 var showSpeed = 3500; 31 var tourOn = false; 32 33 function genLayer(sName, sLeft, sTop, sWdh, sHgt, sVis, copy) { 34 if (NN) { 35 document.writeln('<LAYER NAME="' + sName + '" LEFT=' + sLeft + 36 ' TOP=' + sTop + ' WIDTH=' + sWdh + ' HEIGHT=' + sHgt + 37 ' VISIBILITY="' + sVis + '"' + ' Z-INDEX=' + (++zIdx) + '>' + 38 copy + '</LAYER>'); 39 } 40 else { 41 document.writeln('<DIV ID="' + sName + 42 '" STYLE="position:absolute; overflow:none;left:' + sLeft + 43 'px; top:' + sTop + 'px; width:' + sWdh + 'px; height:' + sHgt + 44 'px;' + ' visibility:' + sVis + '; z-Index=' + (++zIdx) + '">' + 45 copy + '</DIV>'); 46 } 47 } 48 ...

Get JavaScript Application Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.