Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap

Q1183 How can I find out the width in pixels of a character?

You are here: irt.org | FAQ | DHTML | Q1183 [ previous next ]



<script language="JavaScript"><!--
function size() {
    var output = '', letters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
    for (var i=0; i<letters.length; i++) {
        letter = letters.substring(i,i+1);
        if (document.all) output += letter + '=' + document.all[letter].clientWidth + '\n';
        else if (document.layers) output += letter + '=' + document.layers[letter].clip.width + '\n';

<style type="text/css"><!--
.hidden { position: absolute; visibility: hidden; }


<body onLoad="size()">

<div id="A" class="hidden">A</div>
<div id="B" class="hidden">B</div>
<div id="C" class="hidden">C</div>
<div id="D" class="hidden">D</div>
<div id="E" class="hidden">E</div>
<div id="F" class="hidden">F</div>
<div id="G" class="hidden">G</div>
<div id="H" class="hidden">H</div>
<div id="I" class="hidden">I</div>
<div id="J" class="hidden">J</div>
<div id="K" class="hidden">K</div>
<div id="L" class="hidden">L</div>
<div id="M" class="hidden">M</div>
<div id="N" class="hidden">N</div>
<div id="O" class="hidden">O</div>
<div id="P" class="hidden">P</div>
<div id="Q" class="hidden">Q</div>
<div id="R" class="hidden">R</div>
<div id="S" class="hidden">S</div>
<div id="T" class="hidden">T</div>
<div id="U" class="hidden">U</div>
<div id="V" class="hidden">V</div>
<div id="W" class="hidden">W</div>
<div id="X" class="hidden">X</div>
<div id="Y" class="hidden">Y</div>
<div id="Z" class="hidden">Z</div>
<div id="a" class="hidden">a</div>
<div id="b" class="hidden">b</div>
<div id="c" class="hidden">c</div>
<div id="d" class="hidden">d</div>
<div id="e" class="hidden">e</div>
<div id="f" class="hidden">f</div>
<div id="g" class="hidden">g</div>
<div id="h" class="hidden">h</div>
<div id="i" class="hidden">i</div>
<div id="j" class="hidden">j</div>
<div id="k" class="hidden">k</div>
<div id="l" class="hidden">l</div>
<div id="m" class="hidden">m</div>
<div id="n" class="hidden">n</div>
<div id="o" class="hidden">o</div>
<div id="p" class="hidden">p</div>
<div id="q" class="hidden">q</div>
<div id="r" class="hidden">r</div>
<div id="s" class="hidden">s</div>
<div id="t" class="hidden">t</div>
<div id="u" class="hidden">u</div>
<div id="v" class="hidden">v</div>
<div id="w" class="hidden">w</div>
<div id="x" class="hidden">x</div>
<div id="y" class="hidden">y</div>
<div id="z" class="hidden">z</div>


©2018 Martin Webb