在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問(wèn)答/HTML/ 在非標(biāo)準(zhǔn)ie8下,關(guān)于setCapture的使用不理解,在元素上設(shè)置了之后只能捕

在非標(biāo)準(zhǔn)ie8下,關(guān)于setCapture的使用不理解,在元素上設(shè)置了之后只能捕獲一次嗎?

<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>無(wú)標(biāo)題文檔</title>
<script>
window.onload = function() {
    
    var aInput = document.getElementsByTagName('input');
    
    aInput[0].setCapture();    
    aInput[0].onclick = function() {//問(wèn)題1
        console.log(1);
        //alert(1);
    }
aInput[0].onmouseleave = function() {
        console.log(3);
    }
    
    aInput[1].onclick = function() {
        alert(2);
    }
    
}
</script>
</head>

<body>
    <input type="button" value="按鈕一" />
    <input type="button" value="按鈕二" />
</body>
</html>

問(wèn)題1:在執(zhí)行aInput[0].onclick全局捕獲之后aInput[0].onmouseleave沒(méi)有執(zhí)行全局捕獲
問(wèn)題2:在執(zhí)行aInput[0].onclick全局捕獲之后;再次執(zhí)行aInput[0].onclick沒(méi)有執(zhí)行全局捕獲
問(wèn)題3:關(guān)于setCapture的使用不理解,在元素上設(shè)置了之后只能捕獲一次嗎?
如果只能捕獲一次,那releaseCapture 就沒(méi)有意義了?

回答
編輯回答
念初

setCapturereleaseCapture 這兩個(gè)函數(shù)很像是 Windows 下的函數(shù)(因?yàn)樽烂鎽?yīng)用開(kāi)發(fā)里有),所以去查了一下,果然,說(shuō)是基于 IE 實(shí)現(xiàn),沒(méi)說(shuō)有哪些瀏覽器兼容該實(shí)現(xiàn)。

然后 setCapture 文檔的第一段就說(shuō)明了,捕捉狀態(tài)在松開(kāi)按鈕或 releaseCapture 的時(shí)候結(jié)束

Call this method during the handling of a mousedown event to retarget all mouse events to this element until the mouse button is released or document.releaseCapture() is called.

2017年9月19日 03:06