Difference in clientX and clientY when going out of the browser on ie/ff
- by Py
I just ran into a little problem with clientX and clientY.
I put a little event to detect if the mouse goes out of the window and to know where it exits. And there come the trouble, it works fine with firefox, but only sends -1 as an answer in IE. Does someone know if there is a way to solve easily that problem and that without using a framework?
A little bit of code to reproduce that:
<html>
<head>
<script type="text/javascript">
document.onmouseout=function(e){
if (!e) var e = window.event;
var relTarg = e.relatedTarget || e.toElement;
if (!relTarg){
document.getElementById('result1').innerHTML="e.clientY:"+e.clientY+" e.clientX:"+e.clientX;
}
};
</script>
</head>
<body>
<div id="result1">Not Yet</div>
</body>
</html>
the results if I exit through the left of the window are:
e.clientY:302 e.clientX:-130 on firefox
e.clientY:-1 e.clientX:-1 on ie.
Thanks in advance.