Hiding and Displaying Layers

Although your HTML, CSS, and JavaScript combine to make a single document, it’s sometimes useful to make it appear as if you actually have multiple documents—that is, using a combination of CSS and JavaScript, you can have something like a pop-up window display inside—or on top of—your current HTML page. No, this doesn’t use the obsolete Netscape layer tag; it just appears to be a separate layer so far as the user is concerned.

This requires three documents: the HTML document (Script 12.10), the CSS style sheet (Script 12.11), and the JavaScript file (Script 12.12). We’re using JavaScript to manipulate an image using the id assigned in the HTML, and CSS to set the positioning for our annoying advertisement on the ...

Get JavaScript and Ajax for the Web: Visual QuickStart Guide, Seventh Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.