——-test code(test.html)————
<!DOCTYPE html>
<html>
<head>
<style>
*{padding:0px;margin:0px;}
</style>
</head>
<body style="background-color:orange;">
<b onmousemove="tip(this);">A</b> <b>B</b> <b>C</b><!--tip:when mouse is at here the same trigger the function tip()//-->
<fieldset>
<legend id="mouseDot" style="display:block;background-color:red;height:5px;width:200px;"></legend>
<div style="background-color:white;" id="tipTxt">onload mouseDot(red line) width=200px</div>
</fieldset>
<script>
function tip(tag) {
mouseDot.style.width = event.x + 'px';
tipTxt.innerHTML = 'mouse is move at x=' + event.x + ';so mouseDot(red line) width= ' + event.x + 'px';
}
</script>
</body>
</html>
Test environment is IE 9 (view mode is any one, but document mode is IE 8);
when your mouse move at A,it can call function tip() is normal;
but when move at <!--tip:when mouse is at here the same trigger the function tip()//--> ,why it call function tip() too?
You can see what happens on my blog with some screenshots: http://hi.baidu.com/qidizi/blog/item/2322e1f7335b074e342acc46.html
tip:Blog post has been modified, it should be more clearly
why the A can jump to <!--tip:when mouse is at here the same trigger the function tip()//-->,Only 3 pixel sizes, only reacts to mouse events, click on the event is invalid ?
It is the way IE handles white space in this document mode. If you move the fieldset tag up so that it is right next to the last tag, the issue goes away. Like this:
Not a great solution, but it works when you see this quirkly behavior. I have also used this trick when IE secretly inserts some mysterious vertical spacing when you aren’t expecting it.