本文实例讲述了射流研究…实现自动切换文字的导航效果代码。分享给大家供大家参考。具体如下:
这里介绍支持自动切换文字的导航菜单效果,实际上看上去并不像菜单,猛一看倒像是一个挑选下拉框,两侧带有箭头控制按钮,点击左侧则向上切换菜单文字,点击右侧则切换到一个菜单项内容,也可自动切换,鼠标不点击的时候菜单会自动变化文字。
运行效果截图如下:
在线演示地址如下:
http://演示。JB 51。net/js/2015/js-auto-cha-font-nav-style-codes/
具体代码如下:
HTMLHEADTITLE变化的文字导航条/title MetA http-equiv=Content-Type Content=' text/html;charset=GB 2312 '/流浆池bgColor=#fef4d9CENTER变化的文字导航条/CENTBRCENTRABLE BOrder color=# 99 ffff BOrder=5 BOrder light=' green ' TBODY TR TD style。scroller样式{ BOrder-right : # 00000 1px实心;边框-顶部: #000000 1px固体;背景# ffffff边框-左侧: #000000 1px实心;CURSOR:手动;边框-底部: #000000 1px实心;FONT-FAMILY : web dings }/STYLe script语言=JavaScript var msgs=new Array('欢迎光临小站', '网易娱乐', '搜狐门户', '央视国际' );var msg _ URL=新数组(' http://www。新浪。' com ',' http://www.163.com ',' http://www.sohu.com ',' http://www。央视。com’);var target_url=新数组("0"、"0"、"0"、"1");var栏宽=350/以像素或%var setdelay=2000为单位输入主条宽度//以mili-seconds var mouse over _ color=' # b5d 0ff '/指定高亮color var mouse out _ color=' # FFFFFF '/指定默认颜色变量计数=0;var ns6=document.getElementById!文件。all var ie4=文档。全是导航员。用户代理。index of(' Opera ')=-1 if(ie4 | | ns6){ document。write(' form name=' news _ bar ' input type=' button ' value=' 3 ' onclick=' move it(0)' class=' scroller style ' style=' width 336022;高度:22;'边框-右侧-宽度' :0 px'名称='上一篇'标题='上一篇新闻'输入类型=' button '名称=' News _ bar _ but ' onclick=' gour();style=' color : # 000000 background : " mouse out _ color ";宽度:“条宽”;高度:22;边框宽度:1;边框颜色: # 000000;光标: hand ' onmouseover=' this。风格。background=mouse over _ color ' onmouseout=' this。风格。background=mouse out _ color ' input type=' button ' value=' 4 ' onclick=' move it(1)' class=' scroller style ' style=' width :22;高度:22;'边框-左侧-宽度' :0 px'name=' Next ' title=' Next News '/form ');} else { document。写入('表单名称=' news _ bar '输入类型=' button '值=' Previous ' onclick=' move it(0)')if(navigator。用户代理。索引(' Opera ')!=-1)文档。write(' input type=' button ' name=' news _ bar _ but ' onclick=' GoUll();style=' width : ' bar width ' ' border=' 0 ' ')else文档。write(' input type=' button ' name=' news _ bar _ but ' onclick=' gour();width=' bar width ' ' border=' 0 ' ')文档。write(' input type=' button ' value=' Next ' onclick=' move it(1)'/form ')}函数init _ news _ bar(){ document。新闻吧。news _ bar _但是。value=msgs[count];}函数移动它(how){ if(how==1){//向前循环if(计数msg。length-1)count else count=0 } else {//如果(count==0)count=msgs,则向后循环。length-1 else count-}文档。新闻吧。news _ bar _但是。value=msgs[count];} function tick _ bar(){ setInterval(' move it(1),setdelay)} function Gour(){ if(target _ URL[count]==' 0 '){ location。href=msg _ URL[计数];} else { window。open(msg _ URL[计数]);} } tick _ bar();//如果不想消息tickinit_news_bar(),删除这一行;/脚本/TD/TR/tbbody/TABLE/CENTER/BODY/HTML希望本文所述对大家的爪哇岛描述语言程序设计有所帮助。