METHOD:  Object::watch Netscape Only Feature, handlerfunction)
The watch method is inherited by every object descended from Object and adds a watchpoint to a property of the method. Whenever a value is assigned to it, it calls up a function allowing you to watch any new value assigned and, if necessary, alter it.
For example, this following code watches the 'name' property of the 'city' object, and if the name 'Leningrad' is assigned to it, it is altered to the city's new name of 'St. Petersburg'. Note the code that is enclosed in the pair of curly braces (an if statement) which is associated with the handlerfunction argument called 'myfunction':
city = {name:"Chicago"}"name", myfunction (property, oldval, newval)
                                       if(newval == "Leningrad")
                                          newval = "St. Petersburg"
                                       return newval
                ) //end of watch method

A watchpoint for a property does not disappear if that property is deleted. It can, however, be removed by using the unwatch method.

Copyright 1999-2001 by Infinite Software Solutions, Inc. All rights reserved.
Trademark Information