22.04.2013 Views

HTML, XHTML & CSS

HTML, XHTML & CSS

HTML, XHTML & CSS

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 13: Scripting Web Pages<br />

JavaScript and <strong>CSS</strong> create this effect by switching between two style sheets:<br />

✓ The sans serif style sheet, sansStyle.css<br />

✓ The serif style sheet, serifStyle.css<br />

Listing 13-1 shows the source code for an example page that contains the<br />

switching mechanism shown in Figure 13-2:<br />

✓ When a user clicks the Sm Sans button on the page, the<br />

styleSwitcher.js script referenced in the element runs<br />

and switches the active style sheet to sansStyle.css. (.js is the file<br />

extension that’s used with JavaScript files, as in the src value for the<br />

script element in Listing 13-1.)<br />

✓ When the user clicks the Lg Serif button, the same script switches to the<br />

serifStyle.css style sheet.<br />

Listing 13-1: Style Switching<br />

<br />

<br />

<br />

Style Changer<br />

<br />

<br />

<br />

<br />

@import url(“complexStyle.css”);<br />

<br />

<br />

<br />

<br />

Change your font:<br />

<br />

<br />

<br />

<br />

<br />

<br />

Replace this paragraph with your own content.<br />

<br />

<br />

<br />

215

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!