get position from specific position to end window
hi all how i can get position from specific position to end window (Browser) dynam开发者_运维百科ic
First, you could hook the mouseMove event on the html . Then, you close the windows when the mouse position inside assigned range.
Here is a simple example for you. The windows automatically close when the mouse move in the range 100 < X < 105 and 100 < Y < 105.
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title> Close Windows</title>
<script type="text/javascript">
function checkPos()
{
var s = 'X=' + window.event.clientX + ' Y=' + window.event.clientY ;
document.getElementById('divCoord').innerText = s;
if(window.event.clientX > 100 && window.event.clientX < 105 && window.event.clientY > 100 & window.event.clientY < 105) {
window.close();
}
}
</script></head>
<body onmousemove=checkPos()>
<div id="divCoord"></div>
</body></html>
精彩评论