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

12. Visual Effects for Stationary Conten... > 12.4. Offering Body Text Size Choice...

Offering Body Text Size Choices to Users

NN 6, IE 5

Problem

You want to let users choose the relative font size for the content of the page.

Solution

Create a user interface element that lets users select from three or four different font sizes. Each choice invokes the changeSizeStyle( ) function shown in the Discussion. This function enables a style sheet whose ID is passed as an argument and disables the rest. All of the related style sheets apply themselves to the body element. As an added bonus, the changeSizeStyle( ) function calls upon the cookies.js library (Recipe 1.9) to preserve the setting to be applied to the page the next time the user visits.

Discussion

This is a three-part solution, involving HTML for the font size controller, style sheets, and scripts. The result is a small controller on the page that lets users select from three font size bases upon which the rest of the page renders, as shown in Figure 12-1.


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


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