js打字效果

JS打字效果

body{

font-family: Arial;

margin-top:0px;

background-repeat:no-repeat;

padding-top:100px;

}

#myContent, #myContent blink{

width:500px;

height:200px;

background:black;

color: #00FF00;

font-family:courier;

}

blink{

display:inline;

}

var charIndex = -1;

var stringLength = 0;

var inputText;

function writeContent(init){

if(init){

inputText = document.getElementById('contentToWrite').innerHTML;

}

if(charIndex==-1){

charIndex = 0;

stringLength = inputText.length;

}

var initString = document.getElementById('myContent').innerHTML;

initString = initString.replace(/

' || nextFourChars=='

'){

theChar  = '

';

charIndex+=3;

}

initString = initString + theChar + "_";

document.getElementById('myContent').innerHTML = initString;

charIndex = charIndex/1 +1;

if(charIndex%2==1){

document.getElementById('blink').style.display='none';

}else{

document.getElementById('blink').style.display='inline';

}

if(charIndex<=stringLength){ setTimeout('writeContent(false)',10); }else{ blinkSpan(); } } var currentStyle = 'inline'; function blinkSpan(){ if(currentStyle=='inline'){ currentStyle='none'; }else{ currentStyle='inline'; } document.getElementById('blink').style.display = currentStyle; setTimeout('blinkSpan()',1000); }

御坂网络欢迎你

你好,我是御坂网络的智能程序,很高兴你打开这个页面.请问你是要加入御坂网络,成为御坂网络的一员吗?

好的,那么请问该怎么称呼你呢?

writeContent(true);

你可能感兴趣的:(js打字效果)