[DHTML]让人郁闷的mouse Capture,为什么总是只能执行一个事件,不能执行后续的事件?...


关于mouse capture的介绍:
http://msdn2.microsoft.com/en-us/library/ms537630.aspx
msdn for VS2005: ms-help://MS.MSDNQTR.v80.chs/MS.MSDN.v80/MS.WEBDEV.v10.en/dhtml/workshop/author/dhtml/overview/mousecapture.htm

按照上面的介绍:"All mouse events fire on an object with setCapture",但下面代码的测试结果是:
1. 页面加载时,就会执行test2的onmousemove事件(我把鼠标移出IE,按F5刷新还是会弹出'move'),为什么加载时就会执行该事件?该事件是怎么触发的?
2. 若保留test2的onmousemove事件(相对下面的3而言),则鼠标点击空白地方,不会弹出任何框,为什么执行了onmouseover事件就不能执行其他事件了?;
3. 若去掉test2的onmousemove事件,当鼠标点击空白地方,只有第一次点击会弹出'2',以后都不会弹出‘1’或‘2’,为什么只有第一次可以弹出来?
4. setCapture()据说可以带参数true或false(The setCapture method accepts an optional Boolean value. By default, the Boolean value is true and the object with mouse capture will fire all events, regardless of the origin. Setting the Boolean to false will cause the object with mouse capture to fire only events contained within it.),但true和false的测试结果是一样的,不知道究竟有啥区别?

 1 None.gif < HTML >
 2 None.gif < body  onload ="loadBody()" >
 3 None.gif        Test1 < br />
 4 None.gif     < id =test1  style ="background-color:red"  onclick ="click1()" > Test </ p >< br />
 5 None.gif     < id =test2  style ="background-color:red"  onclick ="click2()"  onmousemove ="move()" > Test </ p >< br />
 6 None.gif    Test2 < br />
 7 None.gif </ BODY >
 8 ExpandedBlockStart.gifContractedBlock.gif < script > dot.gif
 9InBlock.gif    function loadBody()
10ExpandedSubBlockStart.gifContractedSubBlock.gif    dot.gif{
11InBlock.gif        document.all.test1.setCapture();        
12InBlock.gif        document.all.test2.setCapture();
13ExpandedSubBlockEnd.gif    }

14InBlock.gif    
15InBlock.gif    function click1()
16ExpandedSubBlockStart.gifContractedSubBlock.gif    dot.gif{
17InBlock.gif        alert('1');        
18ExpandedSubBlockEnd.gif    }

19InBlock.gif    
20InBlock.gif    function click2()
21ExpandedSubBlockStart.gifContractedSubBlock.gif    dot.gif{
22InBlock.gif        alert('2');
23ExpandedSubBlockEnd.gif    }

24InBlock.gif    
25InBlock.gif    function move()
26ExpandedSubBlockStart.gifContractedSubBlock.gif    dot.gif{
27InBlock.gif        alert('move');
28ExpandedBlockEnd.gif    }

29None.gif
</ script >
30 None.gif </ HTML >


 

转载于:https://www.cnblogs.com/happyhippy/archive/2007/07/12/815959.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值