How would I discover the text in a block element hidden by overflow:hidden style being set?

S

SolarCanine

Specifically, assume I have a div tag of absolute dimensions. I need
to figure out, first, whether or not the text inside the div tag is
partially hidden by the overflow setting, and if so, what the hidden
text is.

Is this even possible? Obviously, the rendering engine in the browser
"knows" this information, but is it accessible through Javascript?
 
K

km0ti0n

SolarCanine said:
Specifically, assume I have a div tag of absolute dimensions. I need
to figure out, first, whether or not the text inside the div tag is
partially hidden by the overflow setting, and if so, what the hidden
text is.

Is this even possible? Obviously, the rendering engine in the browser
"knows" this information, but is it accessible through Javascript?

Yes it possible to find out using offsetHeight and scrollHeight.

Here's a demo and some script :

http://km0ti0n.blunted.co.uk/viewng.xap?ID=632628407808750000

Hope that helps
 
S

SolarCanine

Ok, that solves the first half of the problem (thanks!) but I'm still
stumped as to how to get to the second piece of information I need
(exactly what text *isn't* being displayed). Alternately, if I could
get Javascript to tell me what text *is* being displayed, I could
always compare that with the complete contents of the block element and
take the difference to know what wasn't being shown.

Thanks again, that's a handy tip about finding out whether or not the
block is overflowing!
 

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

Forum statistics

Threads
473,731
Messages
2,569,432
Members
44,832
Latest member
GlennSmall

Latest Threads

Top