您好,欢迎访问三七文档
当前位置:首页 > 电子/通信 > 综合/其它 > Javascript特效代码大全(1)
字符从天而降脚本说明:第一步:把如下代码加入head区域中SCRIPTlanguage=JavaScriptFPTYPE=dynamicanimation8!--dynamicanimAttr=dynamicanimation8animateElements=newArray()currentElement=0speed=0stepsZoom=8stepsWord=8stepsFly=12stepsSpiral=16steps=stepsZoomstep=0outString=functiondynAnimation8(){varms=navigator.appVersion.indexOf(MSIE)ie4=(ms0)&&(parseInt(navigator.appVersion.substring(ms+5,ms+6))=4)if(!ie4){if((navigator.appName==Netscape)&&(parseInt(navigator.appVersion.substring(0,1))=4)){for(index=document.layers.length-1;index=0;index--){layer=document.layers[index]if(layer.left==10000)layer.left=0}}return}for(index=document.all.length-1;index=document.body.sourceIndex;index--){el=document.all[index]animation=el.getAttribute(dynamicanimAttr,false)if(null!=animation){if(animation==dropWord||animation==flyTopRightWord||animation==flyBottomRightWord){ih=el.innerHTMLoutString=i1=0iend=ih.lengthwhile(true){i2=startWord(ih,i1)if(i2==-1)i2=iendoutWord(ih,i1,i2,false,)if(i2==iend)breaki1=i2i2=endWord(ih,i1)if(i2==-1)i2=iendoutWord(ih,i1,i2,true,animation)if(i2==iend)breaki1=i2}document.all[index].innerHTML=outStringdocument.all[index].style.posLeft=0document.all[index].setAttribute(dynamicanimAttr,null)}if(animation==zoomIn||animation==zoomOut){ih=el.innerHTMLoutString=SPAN+dynamicanimAttr+=\+animation+\style=\position:relative;left:10000;\outString+=ihoutString+=/SPANdocument.all[index].innerHTML=outStringdocument.all[index].style.posLeft=0document.all[index].setAttribute(dynamicanimAttr,null)}}}i=0for(index=document.body.sourceIndex;indexdocument.all.length;index++){el=document.all[index]animation=el.getAttribute(dynamicanimAttr,false)if(null!=animation){if(animation==flyLeft){el.style.posLeft=10000-offsetLeft(el)-el.offsetWidthel.style.posTop=0}elseif(animation==flyRight){el.style.posLeft=10000-offsetLeft(el)+document.body.offsetWidthel.style.posTop=0}elseif(animation==flyTop||animation==dropWord){el.style.posLeft=0el.style.posTop=document.body.scrollTop-offsetTop(el)-el.offsetHeight}elseif(animation==flyBottom){el.style.posLeft=0el.style.posTop=document.body.scrollTop-offsetTop(el)+document.body.offsetHeight}elseif(animation==flyTopLeft){el.style.posLeft=10000-offsetLeft(el)-el.offsetWidthel.style.posTop=document.body.scrollTop-offsetTop(el)-el.offsetHeight}elseif(animation==flyTopRight||animation==flyTopRightWord){el.style.posLeft=10000-offsetLeft(el)+document.body.offsetWidthel.style.posTop=document.body.scrollTop-offsetTop(el)-el.offsetHeight}elseif(animation==flyBottomLeft){el.style.posLeft=10000-offsetLeft(el)-el.offsetWidthel.style.posTop=document.body.scrollTop-offsetTop(el)+document.body.offsetHeight}elseif(animation==flyBottomRight||animation==flyBottomRightWord){el.style.posLeft=10000-offsetLeft(el)+document.body.offsetWidthel.style.posTop=document.body.scrollTop-offsetTop(el)+document.body.offsetHeight}elseif(animation==spiral){el.style.posLeft=10000-offsetLeft(el)-el.offsetWidthel.style.posTop=document.body.scrollTop-offsetTop(el)-el.offsetHeight}elseif(animation==zoomIn){el.style.posLeft=10000el.style.posTop=0}elseif(animation==zoomOut){el.style.posLeft=10000el.style.posTop=0}else{el.style.posLeft=10000-offsetLeft(el)-el.offsetWidthel.style.posTop=0}el.initLeft=el.style.posLeftel.initTop=el.style.posTopanimateElements[i++]=el}}window.setTimeout(animate();,speed)}functionoffsetLeft(el){x=el.offsetLeftfor(e=el.offsetParent;e;e=e.offsetParent)x+=e.offsetLeft;returnx}functionoffsetTop(el){y=el.offsetTopfor(e=el.offsetParent;e;e=e.offsetParent)y+=e.offsetTop;returny}functionstartWord(ih,i){for(tag=false;iih.length;i++){c=ih.charAt(i)if(c=='')tag=trueif(!tag)returniif(c=='')tag=false}return-1}functionendWord(ih,i){nonSpace=falsespace=falsewhile(iih.length){c=ih.charAt(i)if(c!='')nonSpace=trueif(nonSpace&&c=='')space=trueif(c=='')returniif(space&&c!='')returnii++}return-1}functionoutWord(ih,i1,i2,dyn,anim){if(dyn)outString+=SPAN+dynamicanimAttr+=\+anim+\style=\position:relative;left:10000;\outString+=ih.substring(i1,i2)if(dyn)outString+=/SPAN}functionanimate(){el=animateElements[currentElement]animation=el.getAttribute(dynamicanimAttr,false)step++if(animation==spiral){steps=stepsSpiralv=step/stepsrf=1.0-vt=v*2.0*Math.PIrx=Math.max(Math.abs(el.initLeft),200)ry=Math.max(Math.abs(el.initTop),200)el.style.posLeft=Math.ceil(-rf*Math.cos(t)*rx)el.style.posTop=Math.ceil(-rf*Math.sin(t)*ry)}elseif(animation==zoomIn){steps=stepsZoomel.style.fontSize=Math.ceil(50+50*step/steps)+%el.style.posLeft=0}elseif(animation==zoomOut){steps=stepsZoomel.style.fontSize=Math.ceil(100+200*(steps-step)/steps)+%el.style.posLeft=0}else{steps=stepsFlyif(animation==dropWord||animation==flyTopRightWord||animation==flyBottomRightWord)steps=stepsWorddl=el.initLeft/stepsdt=el.initTop/stepsel.style.posLeft=el.style.posLeft-dlel.style.posTop=el.style.posTop-dt}if(step=steps){el.style.posLeft=0el.style.posTop=0currentElement++step=0}if(currentElementanimateElements.length)window.setTimeout(animate();,speed)}//--/SCRIPT第二步:把如下代码加入body区域中(
本文标题:Javascript特效代码大全(1)
链接地址:https://www.777doc.com/doc-4348443 .html