By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,818 Members | 2,089 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,818 IT Pros & Developers. It's quick & easy.

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

P: n/a
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?

Sep 20 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a

SolarCanine wrote:
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....28407808750000

Hope that helps

Sep 20 '05 #2

P: n/a
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!

Sep 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.