|
Figure 2: Customizing a Web site based on window size. Continued from Figure 1: Setting style rules for IE and Navigator. <html> <head> <style id="ssA" type="text/css"></style> <script language="JavaScript"> <!-- if (document.layers) { if (window.innerWidth < 600) { //set tag sizes for small screens such as: document.tags.h1.fontSize="25pt"; } else { //set tag sizes for large screens such as: document.tags.h1.fontSize="50pt"; } } // --> </script> </head> <body> <script language="JavaScript"> <!-- if (document.all) { if (document.body.clientWidth < 600) { //add style rules for small screens such as: document.styleSheets["ssA"].addRule ("h1", "font-size:25pt"); } else { //add style rules for large screen such as: document.styleSheets["ssA"].addRule ("h1", "font-size:50pt"); } } // --> </script> <h1>JavaScript-Powered Stylesheets</h1> </body> </html> Next: Figure 3: Creating a Web site for all seasons. Published as Internet Builder in the 5/4/99 issue of PC Magazine. Related Links |
|
TOP |
Copyright (c) 1999 Ziff-Davis Inc. |