这里介绍支持自动切换文字的导航菜单效果,实际上看上去并不像菜单,猛一看倒像是一个Select下拉框,两侧带有箭头控制按钮,点击左侧则向上切换菜单文字,点击右侧则切换到一个菜单项内容,也可自动切换,鼠标不点击的时候菜单会自动变化文字。
运行效果截图如下:
在线演示地址如下:
具体代码如下:
<HTML> <HEAD> <TITLE>变化的文字导航条</TITLE> <META http-equiv=Content-Type content="text/html; charset=gb2312"> </HEAD> <BODY bgColor=#fef4d9> <CENTER>变化的文字导航条</CENTER><BR> <CENTER> <TABLE borderColor=#99FFFF border=5 borderlight="green"> <TBODY> <TR> <TD> <STYLE>.scrollerstyle { BORDER-RIGHT: #000000 1px solid; BORDER-TOP: #000000 1px solid; BACKGROUND: #ffffff; BORDER-LEFT: #000000 1px solid; CURSOR: hand; BORDER-BOTTOM: #000000 1px solid; FONT-FAMILY: webdings } </STYLE> <SCRIPT language=javascript> var msgs = new Array( "欢迎光临小站", "网易娱乐", "搜狐门户", "央视国际" ); var msg_url = new Array( "http://www.sina.com", "http://www.163.com", "http://www.sohu.com", "http://www.cctv.com" ); var target_url = new Array( "0", "0", "0", "1" ); var barwidth=350 //Enter main bar width in px or % var setdelay=2000 //Enter delay between msgs, in mili-seconds var mouseover_color='#B5D0FF' //Specify highlight color var mouseout_color='#FFFFFF' //Specify default color var count=0; var ns6=document.getElementById&&!document.all var ie4=document.all&&navigator.userAgent.indexOf("Opera")==-1 if (ie4||ns6){ document.write('<form><input type="button" value="3" title="Previous News"><input type="button"><input type="button" value="4" title="Next News"></form>'); } else{ document.write('<form><input type="button" value="Previous">') if (navigator.userAgent.indexOf("Opera")!=-1) document.write('<input type="button">') else document.write('<input type="button">') document.write('<input type="button" value="Next"></form>') } function init_news_bar(){ document.news_bar.news_bar_but.value=msgs[count]; } function moveit(how){ if (how==1){ //cycle foward if (count<msgs.length-1) count++ else count=0 } else{ //cycle backward if (count==0) count=msgs.length-1 else count-- } document.news_bar.news_bar_but.value=msgs[count]; } function tick_bar(){ setInterval("moveit(1)",setdelay) } function goURL(){ if(target_url[count]=="0") { location.href=msg_url[count]; } else { window.open(msg_url[count]); } } tick_bar(); // delete this line if you don't want messages to tick init_news_bar(); </SCRIPT> </TD></TR></TBODY></TABLE></CENTER> </BODY> </HTML>