Detecting Where Text Wraps

J

Jeff Bigham

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
 
M

Martin Honnen

Jeff said:
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/library/ms536435(VS.85).aspx
An example is here:
http://samples.msdn.microsoft.com/workshop/samples/author/dhtml/refs/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/element.getClientRects
 

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,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top