document.body.clientWidth and Height return 0 if overflow:hidden is set on BODY

RESOLVED FIXED

Status

()

Core
DOM: Core & HTML
RESOLVED FIXED
14 years ago
10 years ago

People

(Reporter: Julian Turner, Unassigned)

Tracking

Trunk
x86
Windows 2000
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Description

14 years ago
User-Agent:       Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.6) Gecko/20040113

If you set style="overflow:hidden" on the BODY, then document.body.clientWidth 
returns 0.

This may not be a bug, but I would consider it a defect compared to IE, which 
does not lose the value.

Reproducible: Always
Steps to Reproduce:
<BODY style="overflow:hidden">
<P onclick="window.alert('document.body.clientWidth')">Test</P>

Actual Results:  
Alerts "0"

Expected Results:  
Should alter (in my view) the client Width.
(Reporter)

Comment 1

14 years ago
Following code seems to demonstrate better.  It does not seem to be every time: 
there are some dependencies at work.

<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="content-type">
<title>test</title>
<script>

function fTest()
{

window.alert(document.body.clientWidth);
}

</script>
</head>
<body style="overflow: hidden;" onload="fTest()">
<div style="position: absolute; left: 10px;">
<p ="" onclick="fTest()">Test<br>
</p>
</div>
</body>
</html>
This is fixed in 1.7rc1 and current trunk, by roc's checkin for bug 234851
Status: UNCONFIRMED → RESOLVED
Last Resolved: 14 years ago
Depends on: 234851
Resolution: --- → FIXED
Note that in general it is correct for an overflow:hidden block with a single
absolute child. no other children, and auto width and height to return a
clientWidth of zero. The only reason this "works" now is that the
overflow:hidden is being removed from the BODY and applied to the viewport.

Updated

10 years ago
Component: DOM: HTML → DOM: Core & HTML
QA Contact: ian → general
You need to log in before you can comment on or make changes to this bug.