Remember, you need not understand programming to use the scripting tech-
niques described in this chapter. Just copy and paste the script element into
the <head>section, and then follow the examples to pass the correct data to
the function (as you just did with the onmouseoverevent in this example).
You can easily customize these examples. If you want the pselector’s text
color to change to green in this example, instead of blue, just make that
change in the code:
<h1 onmouseover=”newrule(‘p’,’font-size: 18px; color:
green’)”>Hover here to drop
Or if you want to change the properties for the headlineselector rather
than the p, just make this change (shown in boldface):
<h1 onmouseover=”newrule(‘h1’,’font-size: 18px; color:
blue’)”>Hover here to drop
This doesn’t work in Firefox.
Timing Things Right ....................................................................................
Another interesting use for scripting is to add timers to your Web pages. You
can use a timer for two purposes: to do something at a specified time (like
setting off an alarm clock at 6 AM) or to repeat something at a particular
interval (like a metronome).
Say that you want to turn a green headline blue — as in the previous
example — but instead of happening when the user hovers or clicks some-
thing, or when the page first loads, you want this event to happen a few
seconds or minutes following the page load. To do that, you use a timer.
In this sample HTML page, I switch to VBScript to create, employ, and then
destroy a timer:
<html>
<head>
<script LANGUAGE=”VBScript”>
function startTimer()
timerhandle = setTimeout(“changehead”,3000)
end function
function stopTimer()
clearTimeout(timerhandle)
end function
290 Part IV: Advanced CSS Techniques