Hi dear~
I got a problem.
Can you help me?
I want to get random font that not borken text(include text of local -> korean text, japan text, english text..) .
I wrote javascript codes that "setInterval" and "Dialog Helper Object".
the below codes are example... so, How can i repair codes?
The codes:
<object id="dlgHelper" classid="clsid:3050f819-98b5-11cf-bb82-00aa00bdce0b" width="0px" height="0px"></object>
<script type="text/javascript">
var CallFuncSpeed = 120;
function GetRndFont() {
try{
var nSystemFontCnt = Math.floor((Math.random()*(dlgHelper.fonts.count))+1);
return dlgHelper.fonts(nSystemFontCnt);
}
catch(err){
document.getElementById('log').innerHTML += nSystemFontCnt;
}
}
function SetRndmFont(){
TextObj.style.fontFamily = GetRndFont();
}
function StartSwitchingFont(){
setInterval("SetRndmFont()",CallFuncSpeed);
}
if(document.all) { //IE
window.onload = StartSwitchingFont;
}
</script>
<div id="log"></div>
<div id="TextObj" style="width:98%;height:30px;text-align:center;font-size:large;background-color:#ddd;">This is a test.</div>
You can have random font. but sometimes, You can seeing broken text...
I don't wana see booken text.
[JSUDDS.MSFT] Your code contained an error. Apparently, the collection of fonts does not start at 0--it starts at 1. So, occasionally your nSystemFontCnt variable would be set to zero, and the object would return an error. I have replaced your code above with a working example.