• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 16. Applied JavaScript > Style Sheet Switcher

Style Sheet Switcher

One of the most powerful uses of DHTML is the ability of JavaScript to, on the fly, modify which style sheet is being used. For example, you can offer your site's visitors the ability to choose the style and size of the text on your site. Some people like to read tiny, sans-serif text that gets lots of words on the screen (Figure 16.8), while others prefer larger, serif text that's a bit more readable (Figure 16.9). Now you can make both kinds of visitors happy. This example takes advantage of some complex interactions of style sheets and JavaScript to allow our trickery to take place in as many browsers as possible, while making sure older browsers get all the content but no scripting errors. And to make it even more useful, it also uses cookies to store the user's choice for future visits.


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint