How to get amount of USABLE space in div?

J

Jeff

I want to get the amount of space that can be used for content (text
etc) div, but NOT the padding. I have looked at all available
properties, and I do not see anything that applies.

The div may or may not have a scrollbar.

How can I do this?
 
T

Thomas 'PointedEars' Lahn

Jeff said:
I want to get the amount of space that can be used for content (text
etc) div,
OK.

but NOT the padding.

That goes without saying.
I have looked at all available
properties, and I do not see anything that applies.
The div may or may not have a scrollbar.

Try the `scrollWidth' and `scrollHeight' properties. But you probably do
not need or want scripting for this; use width: 100% instead.


PointedEars
 
J

Jeff

That goes without saying.


Try the `scrollWidth' and `scrollHeight' properties.  But you probably do
not need or want scripting for this; use width: 100% instead.

PointedEars

I needed to be able to get that size using javascript in a generic
way.

But, that did give me an idea. For width, I put another div in there,
stretch it out to 100% width then get the width in pixels using
offsetWidth. There are some other issues I have to deal with as well
but the concept works. Thanks.
 
T

Thomas 'PointedEars' Lahn

Jeff said:
Thomas said:
Jeff said:
I want to get the amount of space that can be used for content (text
etc) div, [...]
The div may or may not have a scrollbar.

Try the `scrollWidth' and `scrollHeight' properties. But you probably do
not need or want scripting for this; use width: 100% instead.
[...]
I needed to be able to get that size using javascript in a generic
way.

But, that did give me an idea. For width, I put another div in there,
stretch it out to 100% width then get the width in pixels using
offsetWidth. There are some other issues I have to deal with as well
but the concept works. Thanks.

Or, instead of that kludge, you use the `scrollWidth' property of the
"outer" DIV element as I suggested, which you might have noticed earlier had
you quoted properly.

<http://jibbering.com/faq/#posting>


PointedEars
 
J

Jeff

Jeff said:
Thomas said:
Jeff wrote:
I want to get the amount of space that can be used for content (text
etc) div, [...]
The div may or may not have a scrollbar.
Try the `scrollWidth' and `scrollHeight' properties.  But you probably do
not need or want scripting for this; use width: 100% instead.
[...]
I needed to be able to get that size using javascript in a generic
way.
But, that did give me an idea. For width, I put another div in there,
stretch it out to 100% width then get the width in pixels using
offsetWidth.  There are some other issues I have to deal with as well
but the concept works. Thanks.

Or, instead of that kludge, you use the `scrollWidth' property of the
"outer" DIV element as I suggested, which you might have noticed earlier had
you quoted properly.

<http://jibbering.com/faq/#posting>

PointedEars

My goal is to generically get the amount of usable space for any div,
using Javascript, without the padding. scrollWidth and scrollHeight
include padding. Yes, I must use javascript. That is the whole
point. Sorry you did not understand the question, my quoting is not
to your liking, and you seem to be in a bad mood today.

However, my code works perfectly.

Really, you are unneeded now, but, I thought I would give you the
courtesy of replying, since It just seems by your postings that you
have no real life, and no friends. :)
 
T

Thomas 'PointedEars' Lahn

Jeff said:
Thomas said:
Jeff said:
Thomas 'PointedEars' Lahn wrote:
Try the `scrollWidth' and `scrollHeight' properties. But you probably
do not need or want scripting for this; use width: 100% instead.
[...]

I needed to be able to get that size using javascript in a generic
way.

But, that did give me an idea. For width, I put another div in there,
stretch it out to 100% width then get the width in pixels using
offsetWidth. There are some other issues I have to deal with as well
but the concept works. Thanks.

Or, instead of that kludge, you use the `scrollWidth' property of the
"outer" DIV element as I suggested, which you might have noticed earlier
had you quoted properly.

<http://jibbering.com/faq/#posting>
[...]

Read the FAQ above. Trim your quotes. Don't quote non-referred signatures.
My goal is to generically get the amount of usable space for any div,
using Javascript, without the padding. scrollWidth and scrollHeight
include padding.

Depends. In any case you can determine and subtract the padding if
necessary.
Yes, I must use javascript. That is the whole
point. Sorry you did not understand the question,

ISTM that you did not understand the answer instead.
my quoting is not to your liking,

Nor to anyone else's here, at least considering the regulars. Read the FAQ.
and you seem to be in a bad mood today.

On the contrary. If I was, I would not even have bothered to reply to this
RTFM-style question and this pitiful reply of yours, but simply ignored you.
You should consider yourself lucky.

However, my code works perfectly.

Maybe (you are in no position to make an educated assessment, or you would
not have needed to ask). It's still a kludge, and an unnecessary one at
that.
Really, you are unneeded now, but, I thought I would give you the
courtesy of replying, since It just seems by your postings that you
have no real life, and no friends. :)

FOAD :)


PointedEars
 
J

Jeff

Jeff said:
Thomas said:
Jeff wrote:
Thomas 'PointedEars' Lahn wrote:
Try the `scrollWidth' and `scrollHeight' properties.  But you probably
do not need or want scripting for this; use width: 100% instead.
[...]
I needed to be able to get that size using javascript in a generic
way.
But, that did give me an idea. For width, I put another div in there,
stretch it out to 100% width then get the width in pixels using
offsetWidth.  There are some other issues I have to deal with as well
but the concept works. Thanks.
Or, instead of that kludge, you use the `scrollWidth' property of the
"outer" DIV element as I suggested, which you might have noticed earlier
had you quoted properly.
<http://jibbering.com/faq/#posting>
[...]

Read the FAQ above.  Trim your quotes.  Don't quote non-referred signatures.
My goal is to generically get the amount of usable space for any div,
using Javascript, without the padding. scrollWidth and scrollHeight
include padding.

Depends.  In any case you can determine and subtract the padding if
necessary.

No, It doesn't depend. That's a fact. If you weren't in such a rush
to be a newsgroup ass, you would have known that.

By your postings I can tell you only are here to try so hard to make
yourself feel important, obviously compensating for something in your
real life. :)
 
T

Thomas 'PointedEars' Lahn

Jeff said:
No, It doesn't depend. That's a fact.

In Gecko-1.9.1.6-based browsers like Iceweasel 3.5.6, the padding of
elements with width:auto does not influence the value of the `scrollWidth'
property. So much for your "facts".
If you weren't in such a rush
to be a newsgroup ass, you would have known that.

If you weren't such a loser, you would have double-checked your assumptions
before arguing with a newsgroup regular.
By your postings I can tell you only are here to try so hard to make
yourself feel important, obviously compensating for something in your
real life. :)

You have been warned. *PLONK*
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,818
Latest member
SapanaCarpetStudio

Latest Threads

Top