|
|
O'Reilly Book Excerpts: JavaScript & DHTML Cookbook Cooking with JavaScript & DHTML, Part 4
Editor's note: Short and sweet: that's what our latest sample recipe from JavaScript & DHTML Cookbook is: a quick and simple solution to importing browser- or operating system-specific style sheets. This week's excerpt is from Chapter 11 on "Managing Style Sheets." And next week's recipe will also come from the same chapter--check back here then to learn how to read effective style sheet property values. Recipe 11.5: Importing Browser- or Operating System-Specific Style SheetsNN 4, IE 4 ProblemYou want to load separate external style sheet files for users on different kinds of computers. SolutionUse JavaScript to write
You can combine the browser- or operating system-specific external style
sheets with other fixed
To simplify the validation of your script under strict XHTML, you can move the CSS file loading statements to an external .js file. DiscussionEmploying multiple style sheets for different browsers or operating systems imposes the same maintenance headaches as multiple page implementations for different browsers. Any change you make to the design needs to be adapted for each version and tested thoroughly on the designated platforms. And yet, some applications of CSS styles may create an imperative for separate style sheet rules for Internet Explorer for Windows versions that are not fully CSS-compatible (see Recipe 11.13). See AlsoRecipe 11.13 of JavaScript & DHTML Cookbook about the impact on IE 6 for Windows by CSS-compatibility mode; Recipe 5.5 for detecting the browser's operating system. Danny Goodman has been writing about technology and computers full-time since 1981 and is the author of Dynamic HTML: The Definitive Reference and "The Complete HyperCard Handbook." Return to the Web Development DevCenter. |
|
|
|
|
||||||||