1、33个JavaScript经典效果33个JavaScript经典效果一实用且必用的小脚本代码:脚本1:进入主页以后自动播放声音脚本2:进入主页后自动最大话,省的去在自己单击了self.moveTo(0,0)self.resizeTo(screen.availWidth,screen.availHeight)脚本3:显示现在时间的脚本document.writenow脚本4:显示最后修改时间的脚本document.write(document.lastModified)脚本5:设为首页,加为收藏,加入频道,启动outlook发信设为首页加入收藏加入频道与我联系脚本6:状态栏动态显示现在时间fun
2、ctionsee()window.setTimeout(see(),1000);today=newDate();self.status=today.toString();脚本7:关闭窗口的脚本关闭窗口脚本8:按下F12键,直接返回首页functionlook()if(event.keyCode=123)document.location.href=http:/10.13.31.90/kayvin/if(document.onkeydown=null)document.onkeydown=look脚本9:后退,刷新,前进脚本10:设定时间弹出窗口,4000=4秒,当然你可以自定义function
3、l()window.open(10.13.31.90/kayvin/,name,width=500,height=150,border=0)setTimeout(l(),4000)二鼠标旁边的提示信息,类似与163登录后的页面提示效果:tip/*默认设置定义.*tPopWait=50;/停留tWait豪秒后显示提示。tPopShow=5000;/显示tShow豪秒后关闭提示showPopStep=20;popOpacity=99;/*内部变量定义*sPop=null;curShow=null;tFadeOut=null;tFadeIn=null;tFadeWaiting=null;docume
4、nt.write();document.write(.cPopTextbackground-color:#F8F8F5;color:#000000;border:1px#000000solid;font-color:font-size:12px;padding-right:4px;padding-left:4px;height:20px;padding-top:2px;padding-bottom:2px;filter:Alpha(Opacity=0);document.write();document.write();functionshowPopupText()varo=event.src
5、Element;MouseX=event.x;MouseY=event.y;if(o.alt!=null&o.alt!=)o.dypop=o.alt;o.alt=;if(o.title!=null&o.title!=)o.dypop=o.title;o.title=;if(o.dypop!=sPop)sPop=o.dypop;clearTimeout(curShow);clearTimeout(tFadeOut);clearTimeout(tFadeIn);clearTimeout(tFadeWaiting);if(sPop=null|sPop=)dypopLayer.innerHTML=;d
6、ypopLayer.style.filter=Alpha();dypopLayer.filters.Alpha.opacity=0;elseif(o.dyclass!=null)popStyle=o.dyclasselsepopStyle=cPopText;curShow=setTimeout(showIt(),tPopWait);functionshowIt()dypopLayer.className=popStyle;dypopLayer.innerHTML=sPop;popWidth=dypopLayer.clientWidth;popHeight=dypopLayer.clientHe
7、ight;if(MouseX+12+popWidthdocument.body.clientWidth)popLeftAdjust=-popWidth-24elsepopLeftAdjust=0;if(MouseY+12+popHeightdocument.body.clientHeight)popTopAdjust=-popHeight-24elsepopTopAdjust=0;dypopLayer.style.left=MouseX+12+document.body.scrollLeft+popLeftAdjust;dypopLayer.style.top=MouseY+12+docume
8、nt.body.scrollTop+popTopAdjust;dypopLayer.style.filter=Alpha(Opacity=0);fadeOut();functionfadeOut()if(dypopLayer.filters.Alpha.opacity0)dypopLayer.filters.Alpha.opacity-=1;tFadeIn=setTimeout(fadeIn(),1);document.onmouseover=showPopupText;三如果文字过长,则将过长的部分变成省略号显示:就是比如有一行文字,很长,表格内一行显示不下.四滚动的图片:imgArr=ne
9、wArray()imgArr0=imgArr1=imgArr2=imgArr3=imgArr4=varmoveStep=4/步长,单位:pixelvarmoveRelax=100/移动时间间隔,单位:msns4=(document.layers)?true:falsevardisplayImgAmount=4/视区窗口可显示个数vardivWidth=220/每块图片占位宽vardivHeight=145/每块图片占位高varstartDnum=0varnextDnum=startDnum+displayImgAmountvartimeIDvaroutHover=falsevarstartDi
10、vClipLeftvarnextDivClipRightfunctioninitDivPlace()if(ns4)for(i=0;idisplayImgAmount;i+)eval(document.divOuter.document.divAds+i+.left=+divWidth*i)for(i=displayImgAmount;iimgArr.length;i+)eval(document.divOuter.document.divAds+i+.left=+divWidth*displayImgAmount)elsefor(i=0;idisplayImgAmount;i+)eval(do
11、cument.all.divAds+i+.style.left=+divWidth*i)for(i=displayImgAmount;iimgArr.length;i+)eval(document.all.divAds+i+.style.left=+divWidth*displayImgAmount)functionmvStart()timeID=setTimeout(moveLeftDiv,moveRelax)functionmvStop()clearTimeout(timeID)functionmoveLeftDiv()if(ns4)for(i=0;idivWidth)eval(docum
12、ent.divOuter.document.divAds+nextDnum+.clip.right=+divWidth)eval(document.divOuter.document.divAds+startDnum+.left=+divWidth*displayImgAmount)eval(document.divOuter.document.divAds+parseInt(nextDnum+1)%imgArr.length)+.left=document.divOuter.document.divAds+nextDnum+.left+divWidth)eval(document.divOu
13、ter.document.divAds+parseInt(nextDnum+1)%imgArr.length)+.clip.left=0)startDnum=(+startDnum)%imgArr.lengthnextDnum=(startDnum+displayImgAmount)%imgArr.lengthstartDivClipLeft=moveStep-(divWidth-startDivClipLeft)nextDivClipRight=moveStep-(divWidth-nextDivClipRight)elseeval(document.divOuter.document.di
14、vAds+nextDnum+.clip.left=0)startDivClipLeft+=moveStepnextDivClipRight+=moveStepeval(document.divOuter.document.divAds+startDnum+.clip.left=+startDivClipLeft)eval(document.divOuter.document.divAds+nextDnum+.clip.right=+nextDivClipRight)elsefor(i=0;idivWidth)eval(document.all.divAds+nextDnum+.style.cl
15、ip=rect(0,+divWidth+,+divHeight+,0+)eval(document.all.divAds+startDnum+.style.left=+divWidth*displayImgAmount)eval(document.all.divAds+parseInt(nextDnum+1)%imgArr.length)+.style.left=document.all.divAds+nextDnum+.style.pixelLeft+divWidth)startDnum=(+startDnum)%imgArr.lengthnextDnum=(startDnum+displa
16、yImgAmount)%imgArr.lengthstartDivClipLeft=moveStep-(divWidth-startDivClipLeft)nextDivClipRight=moveStep-(divWidth-nextDivClipRight)elsestartDivClipLeft+=moveStepnextDivClipRight+=moveStepeval(document.all.divAds+startDnum+.style.clip=rect(0,+divWidth+,+divHeight+,+startDivClipLeft+)eval(document.all.divAds+nextDnum+.style.clip=rect(0,+nextDivClipRight+,+divHeight+,0)if(outHover)mvStop()elsemvStart()functionwriteDivs()if(ns4)document.write()for(i=0;iimgArr.length;i+)document.write()document.write(imgArri+)
copyright@ 2008-2023 冰点文库 网站版权所有
经营许可证编号:鄂ICP备19020893号-2