|
To access the contents, click the chapter and section titles.
Platinum Edition Using HTML 4, XML, and Java 1.2
Listing 27.2 cbdhtml.js (excerpt)Function Used to Create Layer function createLayer(name, left, top, width, height, visible, content) { var z = layerList.length; var layer; ; layerList[z] = name; ; if (document.layers) { document.writeln(<layer name= + name + left= + left + top= + top + width= + width + height= + height + visibility= + (visible ? show : hide) + z-index= + z + >); document.writeln(content); document.writeln(</layer>); layer = getLayer(name); layer.width = width; layer.height = height; } if (document.all) { document.writeln(<div id= + name + style=position:absolute;overflow:none;left: + left + px; top: + top + px; width: + width + px; height: + height + px; + visibility: + (visible ? visible; : hidden;) + z-index: + z + >); document.writeln(content); document.writeln(</div>); } clipLayer(name, 0, 0, width, height); } As you can see from Listing 27.2, and as mentioned at the beginning of this section, this function tests for the existence of the document.layers or document.all object to determine whether Netscape Navigator or Microsoft Internet Explorer is being used. One of the advantages of this approach is that older versions of these browsers will not generate an error because of this function; because neither object exists, this function will do nothing in those browsers.
Listing 27.3 cbdhtml.js (excerpt)Replace the Content of a Layer function replaceContent(name, content) { if (document.layers) { var layer = getLayer(name); layer.document.open(); layer.document.writeln(content); layer.document.close(); } else if (document.all) { var str = document.all. + name + .innerHTML = + content + ; eval(str); } }
Cross-Browser Dynamic HTML Library ExamplesA number of examples are on the Web site at which you can download the Cross-Browser Dynamic HTML library, all of which work with both Netscape Navigator and Microsoft Internet Explorer. Figure 27.7 shows an example of the animation that is possible using style sheet positioning. When you click the Start button, the colored balls begin orbiting the current mouse position. As you move the mouse pointer around, the balls follow.
The next example shows how you can create content that automatically scrolls through a region of your Web browser window. In Figure 27.8, the mouse pointer is over the Up hypertext link, the Web page has scrolled all the way up to the top. When the mouse pointer is moved over the Down hypertext link, as shown in Figure 27.9, the text containing the U.S. Constitution begins to scroll downward. These examples and many others, along with their full source code, can be found through Mike Halls Cross-Browser Dynamic HTML library Web page at http://members.aol.com/MHall75819/dhtml/cbdhtml.html.
|
Products | Contact Us | About Us | Privacy | Ad Info | Home
Use of this site is subject to certain Terms & Conditions, Copyright © 1996-2000 EarthWeb Inc. All rights reserved. Reproduction whole or in part in any form or medium without express written permission of EarthWeb is prohibited. Read EarthWeb's privacy statement. |