Forum Moderators: open
<html><head>
<title>Test</title>
<style type="text/css">
.fonttest
{
width: auto;
padding: 0;
height: auto;
position: absolute;
left: 0; top: 0px;
line-height: 1.2em;
visibility: hidden;
}
</style>
<script type="text/javascript">function doTest()
{
alert(testFont(document.getElementById('fontbox').value))
}function testFont(font)
{
var control = document.getElementById('control');
var test = document.getElementById('test');
test.style.fontFamily = font;
return control.offsetWidth!= test.offsetWidth;
}
</script>
</head>
<body>
<div id="control" class="fonttest">How wide is this text?</div>
<div id="test" class="fonttest">How wide is this text?</div><input type="button" onclick="doTest()" value="Enter font">
<input type="text" id="fontbox">
</body>
</html>