468,243 Members | 2,037 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,243 developers. It's quick & easy.

Detecting Where Text Wraps

Hi,

If I have a DIV containing a single text node, is there a way to
detect where (or if) the text in that node wraps?

<div>
Some text that possibly wraps to a second line.
</div>

I'd very much appreciate if someone could point me in the right
direction, or even tell me that it's not likely to be easily
accomplished.

Thanks,
Jeff
Aug 23 '08 #1
1 1642
Jeff Bigham wrote:
If I have a DIV containing a single text node, is there a way to
detect where (or if) the text in that node wraps?

<div>
Some text that possibly wraps to a second line.
</div>
IE exposes a method getClientRects which you could call on the div
element object and check the length property of the collection returned.
If it is greater than one then there are at least two lines of text in
the div. Each item in the collection is a TextRectangle object with
properties that should allow you to find where the text wraps
See
http://msdn.microsoft.com/en-us/libr...35(VS.85).aspx
An example is here:
http://samples.msdn.microsoft.com/wo...s/rectdemo.htm

I think Firefox 3.0 implements that method too but I have so far not
used it with Firefox so I don't know how compatible the implementations are.
http://developer.mozilla.org/en/DOM/...getClientRects
--

Martin Honnen
http://JavaScript.FAQTs.com/
Aug 23 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Csaba2000 | last post: by
reply views Thread by Ron H. | last post: by
9 posts views Thread by D. Shane Fowlkes | last post: by
25 posts views Thread by junky_fellow | last post: by
1 post views Thread by mmurrell | last post: by
6 posts views Thread by Andre Majorel | last post: by
reply views Thread by eBob.com | last post: by
reply views Thread by NPC403 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.