Closed Bug 265682 Opened 20 years ago Closed 20 years ago

contentDocument.body.offsetHeight on fail returns old valeu for iframe

Categories

(Core :: DOM: Core & HTML, defect)

x86
Windows XP
defect
Not set
normal

Tracking

()

RESOLVED INVALID

People

(Reporter: mozillabugzilla, Unassigned)

Details

(Keywords: qawanted)

Attachments

(1 file)

3.25 KB, application/x-zip-compressed
Details
User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.3) Gecko/20040910
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.3) Gecko/20040910

When using contentDocument.body.offsetheight to determine the rendered height of
the content in an iframe when a non html page is displayed (example: pdf) an
incorrect value is returned. The value of the previously rendered page is
returned and not 'failed'.

Reproducible: Always
Steps to Reproduce:
--------------------
index.html
--------------------

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html>

<head>
	<title> offsetheight </title>
	<script type="text/javascript">
		function resizeIframe(){

			var currentfr = document.getElementById("contentiframe");

			/* sets the iframe height to the height of the rendered document */
			currentfr.height = currentfr.contentDocument.body.offsetHeight + "px";

		}

		//change the content of the iframe
		function loadLink(link) {
			parent.frames['iframecontent'].location.href = link.href;
		}
	</script>
</head>

<body>

	<a href="test.html" onclick="loadLink(this); return false;">Test html</a>
	<a href="randomNonHtmlFile.pdf" onclick="loadLink(this); return false;">File</a>

	<iframe onload="resizeIframe();" id="contentiframe" name="iframecontent"
src="test.html"></iframe>

</body>

</html>

--------------------
test.html
--------------------

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html>

<head>
	<title> test html file </title>
</head>

<body>

	<h1>Test file</h1>

	<p>some text for the offsetheight.</p>

</body>

</html>
Actual Results:  
Returns offsetheight of previous page

Expected Results:  
Should return a 'null' value or false when trying to access this property.

Problem has been reproduced also on windows 2000 with mozilla 1.7 and on windows
XP sp2 with mozilla 1.6
Live example of this problem can be be delivered on request.
An actual testcase attached to the bug using
https://bugzilla.mozilla.org/attachment.cgi?bugid=265682&action=enter that shows
the problem would be nice.
Component: DOM: Views and Formatting → DOM
Keywords: qawanted
Attached file Working example of bug
Note that the error in height calculation for offsetheight has been entered via
the following bugs:
https://bugzilla.mozilla.org/show_bug.cgi?id=258531
https://bugzilla.mozilla.org/show_bug.cgi?id=258531
Ah, I see.  So the thing is, there _is_ a <body> in that frame (check it in DOM
inspector).  And its height is the height of the frame, since the <embed> that
holds the plugin just uses height="100%".  So the offsetHeight is the height of
the frame.

You'd get the same result with any other content that auto-sized itself to the
viewport, not just with a plugin.

So this is invalid.
Status: UNCONFIRMED → RESOLVED
Closed: 20 years ago
Resolution: --- → INVALID
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: