Closed Bug 540923 Opened 16 years ago Closed 15 years ago

I can't set document.body.scrollTop in DOCTYPE HTML 4.01

Categories

(Core :: DOM: CSS Object Model, defect)

defect
Not set
normal

Tracking

()

RESOLVED INVALID

People

(Reporter: gaddiel.s, Unassigned)

Details

Attachments

(1 file)

User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7 (.NET CLR 3.5.30729) Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7 (.NET CLR 3.5.30729) As seen in https://developer.mozilla.org/En/DOM/Element.scrollTop, I can set the scrollTop proppety. And everything goes well if I don't specify the DOCTYPE but my setting function doesn't work when I add the following line: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> Reproducible: Always Steps to Reproduce: 1.Here is a quick example to demonstrate the problem <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <script type="text/javascript" language="javascript1.5"> function goDown() { document.body.scrollTop=document.body.scrollHeight; } </script> </head> <body> <button onClick="goDown();">Scroll Down</button> <div style="height:5000px; width:500px; background-color:#999999;">Very large div element</div> <button onClick="document.body.scrollTop=0">Scroll Up</button> </body> </html> 2.open it with Mozilla Firefox 5.0 3.click on Scroll Down button 4.change the code removing the first line 5.repeat steaps 2 and 3 6.it works without DOCTYPE especification Actual Results: my Scroll Down button doesn't scroll down the page Expected Results: Scroll down button scrolls the page to the bottom
I suspect you need to set it to <value>px in standards mode. Does that work if you do?
(In reply to comment #1) > I suspect you need to set it to <value>px in standards mode. Does that work if > you do? Thanks Robert for your quick reply but set it with the "px" still that doesn't work, and now it neither works on explorer, here is the example code with the change you suggested <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <script type="text/javascript" language="javascript1.5"> function goDown() { document.body.scrollTop=document.body.scrollHeight+"px"; } </script> </head> <body> <button onClick="goDown();">Scroll Down</button> <div style="height:5000px; width:500px; background-color:#999999;">Very large div element</div> <button onClick="document.body.scrollTop='0px'">Scroll Up</button> </body> </html>
Can you use the Add Attachments link above to add your testcases please instead of pasting them as comments.
(In reply to comment #1) > I suspect you need to set it to <value>px in standards mode. Does that work if > you do? No. This a |long| IDL attribute. In any case, this is expected behaviour per spec: <http://dev.w3.org/csswg/cssom-view/#dom-element-scrolltop>
Status: UNCONFIRMED → RESOLVED
Closed: 15 years ago
Component: DOM: Core & HTML → DOM: CSS Object Model
OS: Windows XP → All
QA Contact: general → style-system
Hardware: x86 → All
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: