Le 9/21/09 3:47 PM, lazy tech newbie a écrit :
Suppose I want to write a text string in Arial font onto my web page,
but first I need to know the width it will take up. Is there any way
to find this out?
Thanks,
No, you want to "display" a text in arial
(if user has this font in his computer)
then you want to know witch could be the size of this text on the user's
screen
maybe :
<p>
<span id="testMesurment">here a little text for testing</span>
<button
onclick="var b = document.getElementById('testMesurment').style;
var s = b.fontSize? (b.fontSize.replace('px','')*1.5)+'px':'14px';
b.fontSize = s; sizer();">increase letters size</button>
<script type="text/javascript">
function sizer()
{alert(document.getElementById('testMesurment').offsetWidth);}
sizer();
</script>
</p>
see :
<
http://www.quirksmode.org/dom/tests/elementdimensions.html>