kr******@gmail.com wrote:
So if I do ...
myObject.myProperty = 5;
I want myObject.myFunction to be called.
Is this possible at all?
Mozilla/Netscape implement getter/setter function for properties e.g.
var object = { _myProperty: undefined };
object.__defineGetter__('myProperty',
function () { return this._myProperty; });
object.__defineSetter__('myProperty',
function (value) { return this._myProperty = value; });
object.myProperty = 'Kibo';
alert(object.myProperty = 'Xibo');
The getter function (anonymous above) is being called when myProperty is
read, the setter function (also anonymous) is called when myProperty is
being assigned to.
But the script engines in browsers like IE or Opera do not support
getter/setter function that way so on the web in general you don't have
that mechanism available.
--
Martin Honnen
http://JavaScript.FAQTs.com/