關于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. 頁面加載時,就會執(zhí)行test2的onmousemove事件(我把鼠標移出IE,按F5刷新還是會彈出'move'),為什么加載時就會執(zhí)行該事件?該事件是怎么觸發(fā)的?
2. 若保留test2的onmousemove事件(相對下面的3而言),則鼠標點擊空白地方,不會彈出任何框,為什么執(zhí)行了onmouseover事件就不能執(zhí)行其他事件了?;
3. 若去掉test2的onmousemove事件,當鼠標點擊空白地方,只有第一次點擊會彈出'2',以后都不會彈出‘1’或‘2’,為什么只有第一次可以彈出來?
4. setCapture()據(jù)說可以帶參數(shù)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的測試結果是一樣的,不知道究竟有啥區(qū)別?
<HTML>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>


浙公網(wǎng)安備 33010602011771號