html中的打字效果

html中的打字效果,第1张

打字效果的文字特效[修改显示的文字即可]

以下代码放在HTML的<body></body>之间[适当的位置]:

<script language=javascript>

var layers =document.layers,style=document.all,both=layers||style,idme=908601

if(layers){layerRef='document.layers'styleRef =''}if(style){layerRef='document.all'styleRef =

'.style'}

function writeOnText(obj,str){

if(layers)with(document[obj]){ document.open()document.write(str)document.close()}

if(style)eval(obj+'.innerHTML=str')}

var dispStr=new Array("这里是你想要打的字")

var overMe=0

function txtTyper(str,idx,idObj,spObj,clr1,clr2,delay,plysnd){

var tmp0=tmp1= '',skip=100

if (both &&idx<=str.length) {

if (str.charAt(idx)=='<'){ while(str.charAt(idx)!='>') idx++idx++}

if (str.charAt(idx)=='&'&&str.charAt(idx+1)!=' '){ while (str.charAt(idx)!= '')idx++idx++}

tmp0 = str.slice(0,idx)

tmp1 = str.charAt(idx++)

if (overMe==0 &&plysnd==1){

if (navigator.plugins[0]){

if(navigator.plugins["LiveAudio"][0].type=="audio/basic" &&navigator.javaEnabled()){document.embeds

[0].stop()

setTimeout("document.embeds[0].play(false)",100)}

} else if (document.all){

ding.Stop()

setTimeout("ding.Run()",100)}

overMe=1}else overMe=0

writeOnText(idObj, "<span class="+spObj+"><font color='"+clr1+"'>"+tmp0+"</font><font color='"+clr2

+"'>"+tmp1+"</font></span>")

setTimeout("txtTyper('"+str+"', "+idx+", '"+idObj+"', '"+spObj+"', '"+clr1+"', '"+clr2+"', "+delay+" ,"+plysnd+")",delay)}}

function init(){txtTyper(dispStr[0], 0, 'ttl0', 'ttl1', '#339933', '#99FF33', 300, 0)}

</script>

<BODY onload=init()>

<DIV class=ttl1 id=ttl0></DIV>

</BODY>

这个肯定行!

<html>

<head>

<meta http-equiv="Content-Type" content="text/htmlcharset=gb2312" />

<title>css 菜单</title>

<style>

body{

background-color:#FFFFFF

}

#fbtn{

/*display:none*/

overflow:hidden

position:relative

width:115px

height:30px

border-style:solid

border-width:1px

border-color:#0e0eff

padding:1px

}

#fbtn_txt{

position:absolute

float:right

right:0px

width:250px

height:30px

}

#fbtn_txt div{

width:115px

height:30px

float:right

padding-top:11px

font-size:9px

font-family:small fonts

color:#800080

text-align:center

cursor:pointer

}

</style>

</head>

<body>

<div id=fbtn>

<div id=fbtn_txt>

<div>G1</div>

<div>good morning</div>

</div>

</div>

<div id=fbtn>

<div id=fbtn_txt>

<div>G2</div>

<div>good evening</div>

</div>

</div>

<div id=fbtn>

<div id=fbtn_txt>

<div>M1</div>

<div>my fhoujun </div>

</div>

</div>

<div id=fbtn>

<div id=fbtn_txt>

<div>M2</div>

<div>mm mm i love u</div>

</div>

</div>

<div id=fbtn>

<div id=fbtn_txt>

<div>G1</div>

<div>good morning</div>

</div>

</div>

<div id=fbtn>

<div id=fbtn_txt>

<div>G2</div>

<div>good evening</div>

</div>

</div>

<div id=fbtn>

<div id=fbtn_txt>

<div>M1</div>

<div>my fhoujun</div>

</div>

</div>

<div id=fbtn>

<div id=fbtn_txt>

<div>M2</div>

<div>mm mm i love u</div>

</div>

</div>

<script>

var current=null

var t=null

for(var i=0i<fbtn.lengthi++){

fbtn[i].index=i

fbtn[i].style.display="block"

fbtn[i].onmouseover=function(){

if(!current){

current=this

domove(this.index)

}

else if(current!=this){

domove(current.index)

domove(this.index)

current=this

}

}

fbtn[i].onmouseout=function(){

if(event.toElement==this.parentElement&t==this){

domove(this.index)

current=null

}

}

}

function domove(i){

var o=fbtn[i].firstChild

var x=fbtn[i].firstChild.firstChild.offsetWidth

if(o.style.posRight<(-x)){

o.style.posRight=0

var t=o.removeChild(o.firstChild)

o.appendChild(t)

}

else{

o.style.posRight-=3

setTimeout('domove('+i+')',15)

}

}

</script>

</body>

</html>


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/6159185.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-03-16
下一篇 2023-03-16

发表评论

登录后才能评论

评论列表(0条)

保存