Click to See Complete Forum and Search --> : DocType mis-behaving in NS7, or...?


Nedals
03-21-2004, 04:31 PM
Here's a simple script. Click on 'Up' and the text moves up.
This works in IE6 and Opera but will NOT work in NS7. Interestingly, if I remove the DocType it works in NS7. (I also tried it with 'DTD HTML 4.01 Transitional' and it doesn't work).

Any Thoughts?

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

<html><head><title>Untitled</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Script-Type" content="text/javascript">
<meta http-equiv="Content-Style-Type" content="text/css">
<script type="text/javascript">
<!--
y = 350;
function moveit(dir) {
var page = document.getElementById('frame').style;
y -= 10;
page.top = y;
return false;
}
//-->
</script>
</head>

<body style="margin:0px; padding:0px; background-color:#fff;">
<div style="position:absolute; top:50px; left:200px; width:400px; height:400px; text-align:center; border:1px solid #000">
<a href="#" onclick="return moveit('U')">Up</a>
</div>
<div id="frame" style="position:absolute; top:350px; left:350px;">Moving Text</div>
</body>
</html>

Sam
03-21-2004, 04:36 PM
instead of top, try pixelTop

Nedals
03-21-2004, 04:50 PM
Originally posted by samij586
instead of top, try pixelTop No Joy :(

fredmv
03-21-2004, 04:51 PM
Originally posted by Nedals
page.top = y + 'px';

Nedals
03-21-2004, 05:19 PM
That did it! :)

Thanks, fredmv

fredmv
03-21-2004, 05:27 PM
No problem whatsoever. If you're wondering why you needed that, it's simply because when you kick the browser into standards-compliance mode with the strict DOCTYPE you must specify the unit in which you'd like to use.