关于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的测试结果是一样的,不知道究竟有啥区别?
2 < body onload ="loadBody()" >
3 Test1 < br />
4 < p id =test1 style ="background-color:red" onclick ="click1()" > Test </ p >< br />
5 < p id =test2 style ="background-color:red" onclick ="click2()" onmousemove ="move()" > Test </ p >< br />
6 Test2 < br />
7 </ BODY >
8 < script >
9 function loadBody()
10 {
11 document.all.test1.setCapture();
12 document.all.test2.setCapture();
13 }
14
15 function click1()
16 {
17 alert('1');
18 }
19
20 function click2()
21 {
22 alert('2');
23 }
24
25 function move()
26 {
27 alert('move');
28 }
29 </ script >
30 </ HTML >