[英]Problems with JavaScript and IE
I made a code that make a div follow the mouse on the window navigator, here is the code: 我编写了一个使div跟随窗口导航器上的鼠标的代码,这是代码:
<script type='text/javascript'>
window.onload = function()
{
window.onmousemove = function(event)
{
var evento = event || window.event;
var bloque = document.getElementById('x');
bloque.style.top = evento.clientY+'px';
bloque.style.left = evento.clientX+'px';
}
}
</script>
BLOQUE 布洛克
It works on firefox but it does not on IE. 它适用于Firefox,但不适用于IE。 It simply does not do anything.
它根本不做任何事情。 What I am doing wrong?
我做错了什么?
var isMSIE = /*@cc_on!@*/0;
if (isMSIE) {
// do IE-specific things
bloque.style.top = window.event.clientY + document.documentElement.scrollTop + document.body.scrollTop+"px";
bloque.style.left = window.event.clientX + document.documentElement.scrollLeft + document.body.scrollLeft+"px";
} else {
// do non IE-specific things
bloque.style.top = event.clientY + window.scrollY+"px";
bloque.style.left = event.clientX + window.scrollX+"px";
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.