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.dt d">
<!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.onmous emove=getMouseP osition;
// get object
window.obj=docu ment.getElement ById('test');
}
function getMousePositio n(e){
var x=(e &&
e.pageX)?e.page X:event.x+docum ent.body.scroll Left;
var y=(e &&
e.pageY)?e.page Y:event.y+docum ent.body.scroll Top;
window.obj.styl e.left=x+'px';
window.obj.styl e.top=y+'px';
document.getEle mentById('test' ).innerHTML="x= "+x+",y="+y+',< br
/>(scrollLeft='+ document.body.s crollLeft+',scr ollTop='+docume nt.body.scrollT op+')';
}
window.onload=i nitPage;
</script>
</head>
<body>
<div id="test"
style="display: block;position: absolute;width: 200px;height:50 px;border:1px
solid black;"></div>
<div style="width:20 0%">
<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.dt d">
<!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.onmous emove=getMouseP osition;
// get object
window.obj=docu ment.getElement ById('test');
}
function getMousePositio n(e){
var x=(e &&
e.pageX)?e.page X:event.x+docum ent.body.scroll Left;
var y=(e &&
e.pageY)?e.page Y:event.y+docum ent.body.scroll Top;
window.obj.styl e.left=x+'px';
window.obj.styl e.top=y+'px';
document.getEle mentById('test' ).innerHTML="x= "+x+",y="+y+',< br
/>(scrollLeft='+ document.body.s crollLeft+',scr ollTop='+docume nt.body.scrollT op+')';
}
window.onload=i nitPage;
</script>
</head>
<body>
<div id="test"
style="display: block;position: absolute;width: 200px;height:50 px;border:1px
solid black;"></div>
<div style="width:20 0%">
<br /><br /><br /><br /><br /><br />
<br /><br /><br /><br /><br /><br />
<br /><br /><br /><br /><br /><br />
</div>
</body>
</html>
Comment