Your scripts may begin as code in Web pages but they ultimately live in a world created by the browser, or client. Smart scripts often need to know more about the world they live in, in which case they can communicate with the browser to find out more about it. Whether it's finding out the screen size or accessing the browser's snooze button, scripts have an awful lot to gain by cultivating their browser relationship.
Download the Code
Code Description and Viewing
The iRock web page from Chapter 1 is continued here, and built incrementally throughout the chapter. Each numbered HTML file corresponds to an incremental version of the web page. When a page number appears beside a file, it is either the page where the file's contents are presented or the exercise (solution) corresponding to the file.
- irock4.html - iRock web page with timer that changes the rock image back to "lonely" (page 96)
- irock5.html - iRock web page that resizes the rock image to the client window when the page first loads (page 104)
- irock6.html - iRock web page that also resizes the rock in response to the onresize window event (page 108)
- irock7.html - iRock web page that uses a cookie to remember the user's name (page 122)
- irock8.html - iRock web page that checks for cookie support (page 128)
- rock.png - Emotionless rock image that appears on the iRock web page
- rock_happy.png - Happy rock image that appears on the iRock web page