Closed Bug 271920 Opened 20 years ago Closed 20 years ago

javascript is unable to set style.left and style.top if doctype is set to HTML 4.01

Categories

(Firefox :: General, defect)

x86
Windows XP
defect
Not set
normal

Tracking

()

VERIFIED INVALID

People

(Reporter: christhumm, Assigned: bugs)

Details

(Keywords: testcase)

Attachments

(1 file)

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; de-DE; rv:1.7.5) Gecko/20041108 Firefox/1.0
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; de-DE; rv:1.7.5) Gecko/20041108 Firefox/1.0

<!--<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/transitional.dtd">-->
<html>
<head>
<title>test</title>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<script language="javascript" type="text/javascript">
<!--
i=0;

function init()
{
   p="testid";
   document.getElementById(p).style.top=150 + 80 * Math.sin(Math.PI *i/40);
   document.getElementById(p).style.left=150 + 80 * Math.cos(Math.PI *i/40);
   setTimeout("init()",100);
   i++;
}
-->
</script>
</head>
<body onLoad="init()" text="#000000" bgcolor="#FFFFFF" link="#FF0000"
alink="#FF0000" vlink="#FF0000">
<div id="testid" style="position:absolute; left:30px; top:30px; width:200px;
height:80px; background-color:#991010;">
</div>
</body>
</html>


Reproducible: Always
Steps to Reproduce:
1.Get the code from Detail
2.uncoment the first line
3.load the page.

Actual Results:  
The red div is not moving.

Expected Results:  
The red div shoudl discribe a circle

if you leave the code as it is it si working but is no valid html 4.01
Attached file Testcase
Added your testcase in HTML 4.01. But simplified.

Making the decleration 
document.getElementById("testid").style.top = "150px"
makes it work.

And this is according the standards. The positioning shemes of the css2
standard. "px" should be used for position values. Not using the doctype puts
the browser into quirks mode.
Yes, you need "px" in Standards mode, see:
http://www.mozilla.org/docs/web-developer/quirks/

-> INVALID
Status: UNCONFIRMED → RESOLVED
Closed: 20 years ago
Keywords: testcase
Resolution: --- → INVALID
Verified invalid.
Status: RESOLVED → VERIFIED
--> Websites :: www.mozilla.com so timeless can close out Firefox :: Product Site.
Component: Product Site → www.mozilla.com
Product: Firefox → Websites
-> Firefox::General (939393)
Component: www.mozilla.com → General
Product: Websites → Firefox
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: