当前位置: 动力学知识库 > 问答 > 编程问答 >

jquery - Mouse events - mousemove in javascript don't respond in IE9

问题描述:

I have a problem with the mousemove event when i have 2 or more canvas elements.

I press the mouse button while the cursor is in the second canvas (v2) then I move the mouse cursor to the first canvas (v1) while still holding the mouse button and let go of the mouse button.

Afterwards when i try to press on the button and move it around in the first canvas (v1) - the event mousemove doesn't work (the index doesn't get index++).

I get a no entry sign when i try to move the mouse inside the first canvas.

it only happens when i try to do it from v2 to v1 but the other way around it works fine.

it only happens on IE9 and not any other web browser that i checked (chrome, FF, IE 10/11).

here is an example code:

<!DOCTYPE html>

<html>

<head>

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js">

</script>

<script>

var index = 0;

$(document).ready(function(){

$("#v1").mousedown(function(){

$("#v1").css("background-color","black");

});

$("#v1").mousemove(function(){

index ++;

$("#v1").css("background-color","red");

});

$("#v2").mousedown(function(){

$("#v2").css("background-color","black");

});

$("#v2").mousemove(function(){

index ++;

$("#v2").css("background-color","red");

});

});

</script>

</head>

<body>

<div id="v1"><canvas width="150" height="150" id="viewer"></canvas></div>

<br/>

<div id="v2"><canvas width="150" height="150" id="viewer2"></canvas></div>

</body>

</html>

分享给朋友:
您可能感兴趣的文章:
随机阅读: