IE9 Mousemove event does not fire during Mousepress

When I left-clicked and dragged the mouse, IE9 does not recognize the mousemove event. I need to know where the mouse is when it moves during depression.

Other browsers work fine.

Here is the gist of my code:

<html> <head> <title>IE9 Failure</title> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script> </head> <body> <div id="imgDiv"><img src="http://upload.wikimedia.org/wikipedia/en/1/1e/Cslewis3.JPG" alt="CS Lewis" /></div> <div id="logger"></div> <script> $('#imgDiv').mousemove(displayMouseXYPos); $('img').mousedown(function(event) { event.preventDefault(); }); var i = 0; function displayMouseXYPos(e) { if (!e) var e = window.event; var x = e.clientX + document.body.scrollLeft; var y = e.clientY + document.body.scrollTop; i++; $('#logger').html(i + ') ' + x + ',' + y); } </script> </body> </html> 

Just click and drag on the image. Observe the data in the "logger" section in Chrome, FF, Safari, Opera, etc. Then check it out in IE9. How to make IE9 behave like others?

Thank you very much!

+4
source share
2 answers

I added the DOCTYPE tag at the beginning of my HTML code and solved the problem:

 <!DOCTYPE html> <html> <head> <title>IE9 Failure</title> ... 

Thanks to everyone who contributed.

0
source

I checked your code on my machine with compatibility mode turned on and got the problem you described. Your browser has compatibility mode enabled.

Add the following meta tag to your page to tell IE to render using the latest version of the render:

 <meta http-equiv="X-UA-Compatible" content="IE=edge" /> 

This tag will also disconnect the user from enabling reconciliation mode for any page to which it is added. Thus, they cannot inadvertently cause it to break.

0
source

All Articles