Watch will monitor this object's property until some time when it changes. When it does, it will invoke
the event handler you define, which MUST have the variables ID,OLDVAL,NEWVAL and return either OLDVAL or NEWVAL.
But you can do all kinds of other things as well like bring up alerts, etc. It's more useful than setTimeout to
monitor some variable because it's "passive" and will be invoked immediately when the property is changed.
For an example, use the default values above, then somewhere in your page, call a javascript that changes the
document.bgColor property and see that an alert will also be invoked.
|