Closed
Bug 304142
Opened 20 years ago
Closed 20 years ago
document.body.clientHeight seems to be wrong when resizing window
Categories
(Firefox :: General, defect)
Tracking
()
RESOLVED
DUPLICATE
of bug 297284
People
(Reporter: jsgoupil, Unassigned)
Details
Attachments
(3 files, 1 obsolete file)
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; fr-FR; rv:1.7.10) Gecko/20050717 Firefox/1.0.6
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.0; fr-FR; rv:1.7.10) Gecko/20050717 Firefox/1.0.6
When trying to resize an applet with JavaScript function, the applet reduces and
disappear from the browser.
It seems that when not using xhtml norms, the applet resize correctly.
In fact, it seems that document.body.clientHeight is wrong with the norms.
Reproducible: Sometimes
Steps to Reproduce:
1. Create a red background applet :
import java.awt.Color;
import javax.swing.JApplet;
import javax.swing.JPanel;
/*
* Created on 2005-08-10
*/
/**
* @author Jean-Sébastien Goupil
*/
public class test extends JApplet{
public void init(){
}
public void start(){
JPanel pan = new JPanel();
pan.setBackground(Color.red);
this.getContentPane().add(pan);
}
}
2. Create jar (test.jar)
3. Create an HTML webpage that resizes the applet when resizing the window with
XHTML norms. Opened in a new window (no tab)
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>test</title>
</head>
<body>
<applet code="test.class" id="bleh" archive="test.jar" width="300" height="200">
</applet>
<script type="text/javascript">
function haha() {
document.getElementById('bleh').width = document.body.clientWidth - 35;
document.getElementById('bleh').height = document.body.clientHeight - 35;
alert(document.body.clientHeight);
}
window.onresize = haha;
</script>
</body>
</html>
Actual Results:
The applet is reducing his height always when resizing the window and disappear
when the height is too short.
Expected Results:
Resize normally
The clientheight seems to be 0 if nothing is in the webpage.
So if it is a problem with the code of clientHeight, why does clientWidth is not
doing the same thing (reducing and desappearing) ?
Comment 1•20 years ago
|
||
Please attach a compiled .jar and the html page to this bug.
Comment 2•20 years ago
|
||
Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.8b4) Gecko/20050810
Firefox/1.0+ ID:2005081009
wfm with a testcase using a div
(open testcase and resize the page)
shouldn't you use
document.getElementById('bleh').style.width i/o
document.getElementById('bleh').width ?
| Reporter | ||
Comment 3•20 years ago
|
||
| Reporter | ||
Comment 4•20 years ago
|
||
| Reporter | ||
Comment 5•20 years ago
|
||
I can't use style.width because it is an applet... but the problem is not there,
it is with the XHTML standard.
Comment 6•20 years ago
|
||
(In reply to comment #5)
> I can't use style.width because it is an applet... but the problem is not there,
> it is with the XHTML standard.
yeah, document.body.clientHeight consistently keeps returning 0 once you've
resized the applet to the point
Comment 7•20 years ago
|
||
proper testcase with <div> showing the behaviour
Attachment #192238 -
Attachment is obsolete: true
Comment 8•20 years ago
|
||
(W/r/t Peter's latest testcase.)
Not a bug. clientHeight is offsetHeight in standards mode
(http://www.quirksmode.org/viewport/compatibility.html). The offsetHeight is
100px, because the only element on the page is 100px. Resize once: goes to 50px.
Resize again: 0px.
| Reporter | ||
Comment 9•20 years ago
|
||
So why the width is not doing the same thing ?
Updated•20 years ago
|
Severity: major → normal
Comment 10•20 years ago
|
||
*** This bug has been marked as a duplicate of 297284 ***
Status: UNCONFIRMED → RESOLVED
Closed: 20 years ago
Resolution: --- → DUPLICATE
Comment 11•20 years ago
|
||
The only element is a display:block element. display:block elements always
expand to the greatest size possible, which is the window width, so clientWidth
behaves like you want it to.
Comment 12•20 years ago
|
||
I'm also opposed to this bug being marked as a duplicate to something else
(especially to an unconfirmed bug) since, as quirksmode states, this is clearly
not a bug at all (invalid would be better).
Comment 13•20 years ago
|
||
(In reply to comment #11)
> The only element is a display:block element. display:block elements always
> expand to the greatest size possible, which is the window width, so clientWidth
> behaves like you want it to.
<body> is the block element, not <div>. Sorry for the confusion.
You need to log in
before you can comment on or make changes to this bug.
Description
•