文字を一文字ずつ表示する
|
| Sample |
| ここをクリックして新しいウインドウを開いてください。 |
| ソース |
<html><head>
<script language="JavaScript">
<!--
a=0;
Strings="こんなんです。";
len=1;
spd=150;
function Disp(){
this_width=350;
this_height=15;
x_add=40;
y_add=0;
x_pos=100;
y_pos=100;
if(document.layers){
document.layers["D_area"].moveTo(x_pos+x_add,y_pos);
document.layers["D_area"].clip.height=this_height;
document.layers["D_area"].clip.width=this_width;
document.layers["D_area"].document.open();
document.layers["D_area"].document.write(Strings.substring(0,len));
document.layers["D_area"].document.close();
}
if(document.all){
document.all("D_area").style.pixelLeft=x_pos+x_add;
document.all("D_area").style.pixelTop=y_pos+y_add;
document.all("D_area").style.height=this_height;
document.all("D_area").style.width=this_width+x_add+x_add;
document.all("D_area").innerHTML=Strings.substring(0,len);
}
len=(Strings.length<len)?0:len+1;
clearTimeout(a);
a=setTimeout('Disp();',spd);}
//-->
</script>
</head>
<body onLoad="Disp();">
<span id="D_area" style="position:absolute;visibility:visible;"></span><br>
</body>
</html>
|
| ワンポイント解説 |
|
表示する文字を変えたいときは、
Strings= の文字列を変えます。 表示するスピードを変えたいときは、spd() 変えます。 |