R
Robert
Hi,
My previous thread on this topic was too short on information so I I'll
try again. When I tried out Firefox 1.5 beta some of my javascript did
not work anymore. Here is some code to illustrate the different
behaviour between Firefox 1.0x and 1.5.
function init()
{
Event.prototype.__defineGetter__("srcElement", function()
{
if (this.constructor == Event)
alert("Constructor is an event");
else
{
alert("Constructor is NOT an event");
alert(this.constructor);
}
return null;
});
}
function test(event)
{
alert(event.srcElement);
}
<button id="testButton" onclick="init();test2(event)">Firefox 1.5
MouseEvent test</button>
Of course normally the init() function would do something useful.
When you click on the button in Firefox 1.0x, the if statement
(this.constructor == Event) returns true. In Firefox 1.5 it returns
false and the alert shows "MouseEvent". It also shows "MouseEvent" when
you use the enter key to 'click' on the button.
So I was wondering why this change was made and if there is still a
possibility if this.constructor can be tested to see if it is some event
(it does not matter to me if it is a MouseEvent or whatever other kind
of Event). I tried to look at the prototype chain of the MouseEvent
hoping that the Event would be in the chain, but it just shows as a
native object.
Okay I hope this was more clear.
Robert.
My previous thread on this topic was too short on information so I I'll
try again. When I tried out Firefox 1.5 beta some of my javascript did
not work anymore. Here is some code to illustrate the different
behaviour between Firefox 1.0x and 1.5.
function init()
{
Event.prototype.__defineGetter__("srcElement", function()
{
if (this.constructor == Event)
alert("Constructor is an event");
else
{
alert("Constructor is NOT an event");
alert(this.constructor);
}
return null;
});
}
function test(event)
{
alert(event.srcElement);
}
<button id="testButton" onclick="init();test2(event)">Firefox 1.5
MouseEvent test</button>
Of course normally the init() function would do something useful.
When you click on the button in Firefox 1.0x, the if statement
(this.constructor == Event) returns true. In Firefox 1.5 it returns
false and the alert shows "MouseEvent". It also shows "MouseEvent" when
you use the enter key to 'click' on the button.
So I was wondering why this change was made and if there is still a
possibility if this.constructor can be tested to see if it is some event
(it does not matter to me if it is a MouseEvent or whatever other kind
of Event). I tried to look at the prototype chain of the MouseEvent
hoping that the Event would be in the chain, but it just shows as a
native object.
Okay I hope this was more clear.
Robert.