Exercises
If you want to gain more experience with user scripts, try the following exercises:
Modify the color-changing user script in Listing 18.2 to use different colors, and add another style attributefor example, use style.fontSize to change the font size. The color-changing example works on paragraphs, but text often appears in other places, such as bullet lists. Modify Listing 18.2 to make the changes to <li> tags as well as paragraphs. Currently, the macro example in the Try It Yourself section only works on text inputs that use <textarea> tags. Modify the script in Listing 18.3 to work on <input> tags also. (You'll need to add a second call to getElementsByTagName() and a loop to add the event handlers.)
|
Main Menu
|