S
somebody
Hello all,
I created a function which gets the position of the mouse. This works fine
untill I insert a doctype declaration in the file. The properties
'scrollLeft' and 'scrollTop' in IE will not change anymore. This means the
javascript is changed based on the doctype?
Is this a bug?
Which functions and properties will change their behaviour in what doctype?
Do I miss something?
Is there a solution?
btw in firefox all works as expected
code:
<!--
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"DTD/xhtml1-strict.dtd">
-->
<html>
<head>
<script type="text/javascript">
function initPage(){
// set onmouse move event handler to capture the mouse
position
document.onmousemove=getMousePosition;
// get object
window.obj=document.getElementById('test');
}
function getMousePosition(e){
var x=(e &&
e.pageX)?e.pageX:event.x+document.body.scrollLeft;
var y=(e &&
e.pageY)?e.pageY:event.y+document.body.scrollTop;
window.obj.style.left=x+'px';
window.obj.style.top=y+'px';
document.getElementById('test').innerHTML="x="+x+",y="+y+',<br
/>(scrollLeft='+document.body.scrollLeft+',scrollTop='+document.body.scrollTop+')';
}
window.onload=initPage;
</script>
</head>
<body>
<div id="test"
style="display:block;position:absolute;width:200px;height:50px;border:1px
solid black;"></div>
<div style="width:200%">
<br /><br /><br /><br /><br /><br />
<br /><br /><br /><br /><br /><br />
<br /><br /><br /><br /><br /><br />
</div>
</body>
</html>
I created a function which gets the position of the mouse. This works fine
untill I insert a doctype declaration in the file. The properties
'scrollLeft' and 'scrollTop' in IE will not change anymore. This means the
javascript is changed based on the doctype?
Is this a bug?
Which functions and properties will change their behaviour in what doctype?
Do I miss something?
Is there a solution?
btw in firefox all works as expected
code:
<!--
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"DTD/xhtml1-strict.dtd">
-->
<html>
<head>
<script type="text/javascript">
function initPage(){
// set onmouse move event handler to capture the mouse
position
document.onmousemove=getMousePosition;
// get object
window.obj=document.getElementById('test');
}
function getMousePosition(e){
var x=(e &&
e.pageX)?e.pageX:event.x+document.body.scrollLeft;
var y=(e &&
e.pageY)?e.pageY:event.y+document.body.scrollTop;
window.obj.style.left=x+'px';
window.obj.style.top=y+'px';
document.getElementById('test').innerHTML="x="+x+",y="+y+',<br
/>(scrollLeft='+document.body.scrollLeft+',scrollTop='+document.body.scrollTop+')';
}
window.onload=initPage;
</script>
</head>
<body>
<div id="test"
style="display:block;position:absolute;width:200px;height:50px;border:1px
solid black;"></div>
<div style="width:200%">
<br /><br /><br /><br /><br /><br />
<br /><br /><br /><br /><br /><br />
<br /><br /><br /><br /><br /><br />
</div>
</body>
</html>