Firefox 1.5中的MouseEvent(2) [英] MouseEvent in Firefox 1.5 (2)

查看:64
本文介绍了Firefox 1.5中的MouseEvent(2)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我之前关于此主题的帖子信息太短,所以我会再次尝试
。当我尝试使用Firefox 1.5测试版时,我的一些javascript确实不再使用了
。下面是一些代码来说明Firefox 1.0x和1.5之间的不同行为。


函数init()

{

Event.prototype .__ defineGetter __(" srcElement",function()

{

if(this.constructor == Event)

alert("构造函数是一个事件);

else

{

alert("构造函数不是event");

alert(this.constructor);

}

返回null;

});

}


功能测试(事件)

{

alert(event.srcElement);

}


< button id =" testButton" onclick =" init(); test2(event)"> Firefox 1.5

MouseEvent测试< / button>


当然通常是init( )函数会做一些有用的事情。

当你点击Firefox 1.0x中的按钮时,if语句

(this.constructor == Event)返回true。在Firefox 1.5中,它返回

false,警报显示MouseEvent。它还显示MouseEvent和MouseEvent。当

时,你可以使用回车键在按钮上点击。


所以我想知道为什么要做出这个改变,如果还有一个

的可能性如果可以测试this.constructor以查看它是否是某个事件

(如果它是MouseEvent或其他任何类型对我来说无关紧要/>
事件)。我试着看一下MouseEvent的原型链

希望事件会在链中,但它只是显示为一个

本机对象。


好​​的,我希望这更清楚。


罗伯特。

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.

推荐答案

Robert写道:
< button id =" testButton" onclick =" init(); test2(event)"> Firefox 1.5
MouseEvent测试< / button>
<button id="testButton" onclick="init();test2(event)">Firefox 1.5
MouseEvent test</button>




test2必须测试



test2 must be test


Robert写道:
这里有一些代码来说明Firefox 1.0x和1.5之间的不同行为。


[一些JS代码]

当然,通常init()函数会做一些有用的事情。
当你点击Firefox中的按钮时1.0x,


FF 1.0.4 ==>错误:未定义test2

在Firefox 1.5中,它还显示MouseEvent。当
使用回车键在按钮上点击时。


我该怎么做?

我有什么可以把重点放在表格上

好​​的我希望这更清楚。
Here is some code to illustrate the different
behaviour between Firefox 1.0x and 1.5.
[some JS code]
Of course normally the init() function would do something useful.
When you click on the button in Firefox 1.0x,
FF 1.0.4 ==> Error : test2 is not defined
In Firefox 1.5 it also shows "MouseEvent" when
you use the enter key to ''click'' on the button.
How do I do that ?
I have anything to give focus to the form
Okay I hope this was more clear.




Huu?

-

Stephane Moriaux et son [moins] vieux Mac



Huu ?
--
Stephane Moriaux et son [moins] vieux Mac


ASM写道:
Robert写道:
Robert wrote:
这里有一些代码来说明
Firefox 1.0x和1.5。
Here is some code to illustrate the different behaviour between
Firefox 1.0x and 1.5.



[一些JS代码]


[some JS code]

当然,通常init()函数会做一些有用的事情。当你点击Firefox 1.0x中的按钮时,
Of course normally the init() function would do something useful.
When you click on the button in Firefox 1.0x,



FF 1.0.4 ==>错误:test2未定义


FF 1.0.4 ==> Error : test2 is not defined




我犯了一个错误。当然必须进行测试。



I made a mistake. It must be test of course.

在Firefox 1.5中,它还显示MouseEvent。当你使用回车键
来点击按钮时。
In Firefox 1.5 it also shows "MouseEvent" when you use the enter key
to ''click'' on the button.



我该怎么做?
我有什么可以把重点放在表单


How do I do that ?
I have anything to give focus to the form




使用选项卡聚焦按钮。



Use tab to focus the button.


这篇关于Firefox 1.5中的MouseEvent(2)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆