faqts : Computers : Programming : Languages : JavaScript : DHTML

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

16 of 25 people (64%) answered Yes
Recently 4 of 10 people (40%) answered Yes

Entry

How to simulate a typewriter scroll

Jul 13th, 2001 17:45
meng xianhui, Rogerio Vianna, amxh@21cn.com


<SCRIPT language=javascript>
<!-- 
var pos=0;
var msg="Welcome to my homepage: http://lucky.myrice.com"; 
function Type(){
pos++;
if (msg.substring(pos-1,pos) == " ")
{
pos++
}
text=msg.substring(0,pos);
if (document.layers)
{
document.layers.layerA.document.open();
document.layers.layerA.document.write("<div 
style='position:absolute;top:0px;left:0px;font-family:Verdana;font-
size:12px;color:#777777'>" + text + "</div>");
document.layers.layerA.document.close();
}
else if (document.all)
document.all.layerA.innerHTML=text;
if (pos < msg.length)
{Tm=setTimeout('Type()',5)}
else
{AlRiGhT=1}
}
window.onload=Type; 
function Demo(aPage,scrll){
if (AlRiGhT==1)
 {clearTimeout(Tm);
 if  (!window.win || win.closed)
 win=open
(aPage,"","top=0,left=0,width=788,height=540,scrollbars="+scrll+",resiza
ble=1");
 else
  {
  win.close(); 
  win=open
(aPage,"","top=0,left=0,width=788,height=540,scrollbars="+scrll+",resiza
ble=1");
  }
 }
}
//-->
</SCRIPT>
<DIV id=layerA  style="FONT-SIZE: 12pt; COLOR: #000099; FONT-FAMILY: 
Verdana; POSITION: relative"></DIV>