Home Articles FAQs XREF Games Software Instant Books About Feedback Search Site-Map
irt.org logo

Q1035 How can I find out the width of text rendered by the document?

irt.org | Knowledge Base | DHTML | Q1035 [ previous next ]

Q1035 How can I find out the width of text rendered by the document?

The following should work on Netscape Navigator 4+ and Internet Explorer 4+:

<body onLoad="textWidth()">

<script language="JavaScript"><!--
function textWidth() {
    if (document.layers)
        alert('width = ' + document.layers['nn'].document.width);
    else if (document.all)
        alert('width = ' + document.all['msie'].clientWidth);
}
//--></script>

<div id="msie">
<layer id="nn">
How long is this string?
</layer>
</div>

Feedback on 'Q1035 How can I find out the width of text rendered by the document?'


Provide feedback ...
AddThis Social Bookmark Button

Provide feedback ... AddThis Social Bookmark Button


Last Updated: 6th July 2009. Maintained by: Martin Webb
irt.org liability, trademark, document use, privacy statement and software licensing rules apply.
Copyright © 1996-2009 irt.org, All Rights Reserved.