Re: Calculating the actual content width or height
- From: David Mark <dmark.cinsoft@xxxxxxxxx>
- Date: Tue, 16 Dec 2008 19:51:17 -0800 (PST)
On Dec 16, 2:15 pm, "Ben Amada" <ben.nojunkplease.am...@xxxxxxxxx>
wrote:
dhtml wrote:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd"> <html lang="en"> <head>
<title>scrollWidth</title>
<script type="text/javascript">
onload = function() {
var d = document.getElementById('d'),
f = document.getElementById('f'),
textContent = "textContent";
if (! (textContent in document.body))
textContent = "innerText";
f[textContent] = d.scrollWidth;
}; </script> </head> <body> <h1>scrollWidth</h1> <div id="d"
style="width: 10px; padding: 100px; background: lime">width: 10px;
padding: 100.5px</div> scrollWidth: <b id="f"></b> </body> </html>
FF 3 scrollWidth: 211
Safari 2, Safari 3, Opera 9.5: scrollWidth: 210
The OP was very specific in that he wants to obtain the content area. I
would also like a simple solution to this problem.
It doesn't seem scrollWidth takes the content width into consideration for
the OP's question. My interpretation is that there is a single line of text
No need to interpret. Read the OP's response: "Thanx. Yes, that
worked." And the scrollWidth property is not a mystery.
that is being scrolled within a div. If the width of that text is greater
than the div width, then scrollWidth just reports the width of the div. I
modified your code to demonstrate this.
That's what he wanted. No need for a demonstration of scrollWidth.
[snip]
.
- Follow-Ups:
- Re: Calculating the actual content width or height
- From: dhtml
- Re: Calculating the actual content width or height
- From: Ben Amada
- Re: Calculating the actual content width or height
- References:
- Calculating the actual content width or height
- From: r_honey
- Re: Calculating the actual content width or height
- From: David Mark
- Re: Calculating the actual content width or height
- From: dhtml
- Re: Calculating the actual content width or height
- From: Ben Amada
- Calculating the actual content width or height
- Prev by Date: Re: getting nulls from window.frames[].document.getElementById
- Next by Date: Re: Javascript Bible 6th Edition (Danny Goodman, Michael Morrison)
- Previous by thread: Re: Calculating the actual content width or height
- Next by thread: Re: Calculating the actual content width or height
- Index(es):
Relevant Pages
|