Click here to Skip to main content
14,427,983 members
Rate this:
Please Sign up or sign in to vote.
See more: (untagged)
Hi,

Is it possible to measure the pixelsize of an innerHTML text?

I want to show the height and width of text.
I tried it with "offsetWidth" and "offsetHeigth", but then you get the dimensions of the fontframe :
http://www.stickers.be/Forum-Images/span.jpg[^]


Take the text in your drawing prog and measure it.
Then break the text apart (convert to outlines). That's the height I need.
See example :
http://www.frogstyling.be/textoutlines.jpg[^]
Posted
Updated 18-Feb-12 5:36am
v3
Comments
Dalek Dave 4-Jan-11 6:51am
   
Edited for Readability.
Rate this:
Please Sign up or sign in to vote.

Solution 2

If you check the DOM, you can probably find the font that is in effect for the particular element, and then determine the height that way.
   
Rate this:
Please Sign up or sign in to vote.

Solution 1

Have a look at the link below. It just might be a style that prevents you from measuring correctly. You could try it and have a look.
http://chamnapchhorn.blogspot.com/2008/06/determine-real-offsetwidthoffsetheight.html[^]

Also, maybe this bug report can help (with the work around given):
http://www.quirksmode.org/bugreports/archives/2005/08/Wrong_offsetWidth_in_Mozilla_and_Opera.html[^]

Good luck!
   
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100