DocType mis-behaving in NS7, or...?

liunx

Guest
Here's a simple script. Click on 'Up' and the text moves up.<br />
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).<br />
<br />
Any Thoughts?<br />
<br />
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"><br />
<br />
<html><head><title>Untitled</title><br />
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <br />
<meta http-equiv="Content-Script-Type" content="text/javascript"> <br />
<meta http-equiv="Content-Style-Type" content="text/css"><br />
<script type="text/javascript"><br />
<!--<br />
y = 350;<br />
function moveit(dir) {<br />
var page = document.getElementById('frame').style;<br />
y -= 10;<br />
page.top = y;<br />
return false;<br />
}<br />
//--><br />
</script><br />
</head><br />
<br />
<body style="margin:0px; padding:0px; background-color:#fff;"><br />
<div style="position:absolute; top:50px; left:200px; width:400px; height:400px; text-align:center; border:1px solid #000"><br />
<a href=http://www.webdeveloper.com/forum/archive/index.php/"#" onclick="return moveit('U')">Up</a><br />
</div><br />
<div id="frame" style="position:absolute; top:350px; left:350px;">Moving Text</div><br />
</body><br />
</html><!--content-->instead of top, try pixelTop<!--content-->Originally posted by samij586 <br />
instead of top, try pixelTop No Joy :(<!--content-->Originally posted by Nedals <br />
page.top = y + 'px';<!--content-->That did it! :)<br />
<br />
Thanks, fredmv<!--content-->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.<!--content-->
 
Back
Top