脚本特效展示
看看上方的导航菜单,可以任意加减的呀,快拿去试试!
以下代码加入<head>区域
<style type=text/css>#menubar { background: rgb(212,208,200); font: menu; cursor: default; position: relative } #menubar .root { border-right: rgb(212,208,200) 1px solid; padding-right: 2pt; border-top: rgb(212,208,200) 1px solid; padding-left: 2pt; border-left: rgb(212,208,200) 1px solid; border-bottom: rgb(212,208,200) 1px solid } #menubar table { border-right: gray 2px solid; padding-right: 0pt; border-top: #eeeeee 2px solid; display: none; padding-left: 0pt; background: rgb(212,208,200); padding-bottom: 0pt; margin: 0pt; font: menu; border-left: #eeeeee 2px solid; padding-top: 0pt; border-bottom: gray 2px solid; position: absolute } #menubar table td { padding-right: 15pt; padding-left: 12pt; padding-bottom: 2pt; margin: 0pt; padding-top: 2pt } #menubar .highlight { background: #08246b; color: white; } #menubar .disabledhighlight { background: rgb(212,208,200); color: gray } #menubar #break { color: gray } #menubar .disabled { color: gray } #menubar #break { padding-right: 0pt; padding-left: 0pt; padding-bottom: 0pt; margin: 0pt; padding-top: 0pt } #menubar span.more { padding-right: 0pt; padding-left: 0pt; left: 14pt; float: right; padding-bottom: 0pt; margin: 0pt; font: 9pt webdings; width: 0.8em; padding-top: 0pt; position: relative; top: -2pt; height: 9pt } #menubar .tbhandle { background-color: menu; border-left: buttonhighlight 1px solid; border-right: buttonshadow 1px solid; border-top: buttonhighlight 1px solid; font-size: 1px; height: 22px; position: absolute; top: 1px; width: 3px } #menubar .ytoolbar { background-color: menu; border-bottom: buttonshadow 1px solid; border-left: buttonhighlight 1px solid; border-right: buttonshadow 1px solid; border-top: buttonhighlight 1px solid; height: 27px; left: 0px; position: relative; top: 0px; } .handbtn { background: buttonface; border-bottom: buttonshadow 1px solid; border-left: buttonhighlight 1px solid; border-right: buttonshadow 1px solid; border-top: buttonhighlight 1px solid; height: 21px; width: 3px } .sepbtn1 { border-left: buttonshadow 1px ridge; border-right: buttonhighlight 1px solid; width: 2px } </style>
以下代码加入<body>区域
<script language=javascript> //数组名+次序号码 //数组内容第一个值为标题 //"样式名称","字体颜色","名称","连接","目标窗口" outbarfolder1=new array( "系统功能", "none","default","新建管理人员","add","_blank", "none","default","浏览管理人员","none","_blank", "none","default","修改管理人员资料","none","_blank", "none","default","更改密码","none","_blank", "none","default","权限分配","none","none", "break","default","<hr>","none","none", "none","default","新建管理人员","add","_blank", "none","default","新建管理人员","add","_blank", "none","default","新建管理人员","add","_blank", "none","default","新建管理人员","add","_blank", "none","default","新建管理人员","add","_blank", "break","default","<hr>","none","none", "none","default","备份数据","none","_top", "none","default","恢复数据","none","_top", "break","default","<hr>","none","none", "none","default","更改个人资料","none","_blank", "none","default","更改个人密码","none","_blank", "break","default","<hr>","none","none", "none","default","退出管理系统","none","_top" ); outbarfolder2=new array( "系统功能", "none","default","新建管理人员","add","_blank", "none","default","浏览管理人员","none","_blank", "none","default","修改管理人员资料","none","_blank", "none","default","更改密码","none","_blank", "none","default","权限分配","none","none", "break","default","<hr>","none","none", "none","default","新建管理人员","add","_blank", "none","default","新建管理人员","add","_blank", "none","default","新建管理人员","add","_blank", "none","default","新建管理人员","add","_blank", "none","default","新建管理人员","add","_blank", "break","default","<hr>","none","none", "none","default","备份数据","none","_top", "none","default","恢复数据","none","_top", "break","default","<hr>","none","none", "none","default","更改个人资料","none","_blank", "none","default","更改个人密码","none","_blank", "break","default","<hr>","none","none", "none","default","退出管理系统","none","_top" ); outbarfolder3=new array( "系统功能", "none","default","新建管理人员","add","_blank", "none","default","浏览管理人员","none","_blank", "none","default","修改管理人员资料","none","_blank", "none","default","更改密码","none","_blank", "none","default","权限分配","none","none", "break","default","<hr>","none","none", "none","default","新建管理人员","add","_blank", "none","default","新建管理人员","add","_blank", "none","default","新建管理人员","add","_blank", "none","default","新建管理人员","add","_blank", "none","default","新建管理人员","add","_blank", "break","default","<hr>","none","none", "none","default","备份数据","none","_top", "none","default","恢复数据","none","_top", "break","default","<hr>","none","none", "none","default","更改个人资料","none","_blank", "none","default","更改个人密码","none","_blank", "break","default","<hr>","none","none", "none","default","退出管理系统","none","_top" ); var childactive = null var menuactive = null var lasthighlight = null var active = false function getreal(el) { // find a table cell element in the parent chain */ temp = el while ((temp!=null) && (temp.tagname!="table") && (temp.classname!="root") && (temp.id!="menubar")) { if (temp.tagname=="td") el = temp temp = temp.parentelement } return el } function raisemenu(el) { el.style.borderleft = "1px #08246b solid" el.style.bordertop = "1px #08246b solid" el.style.borderright = "1px #08246b solid" el.style.borderbottom = "1px #08246b solid" el.style.background = "#b5bed6" } function clearhighlight(el) { if (el==null) return el.style.borderright = "1px lightgrey solid" el.style.borderbottom = "1px lightgrey solid" el.style.bordertop = "1px lightgrey solid" el.style.borderleft = "1px lightgrey solid" el.style.background = "rgb(212,208,200)" } function sinkmenu(el) { el.style.borderright = "1px #eeeeee solid" el.style.borderbottom = "1px #eeeeee solid" el.style.bordertop = "1px gray solid" el.style.borderleft = "1px gray solid" el.style.background = "rgb(212,208,200)" } function menuhandler(menuitem) { // write generic menu handlers here! // returning true collapses the menu. returning false does not collapse the menu return true } function getoffsetpos(which,el,tagname) { var pos = 0 // el["offset" + which] while (el.tagname!=tagname) { pos+=el["offset" + which] el = el.offsetparent } return pos } function getroottable(el) { el = el.offsetparent if (el.tagname=="tr") el = el.offsetparent return el } function getelement(el,tagname) { while ((el!=null) && (el.tagname!=tagname) ) el = el.parentelement return el } function processclick() { var el = getreal(event.srcelement) if ((getroottable(el).id=="menubar") && (active)) { cleanupmenu(menuactive) clearhighlight(menuactive) active=false lasthighlight=null dohighlight(el) } else { if ((el.classname=="root") || (!menuhandler(el))) domenudown(el) else { if (el._childitem==null) el._childitem = getchildren(el) if (el._childitem!=null) return; if ((el.id!="break") && (el.classname!="disabled") && (el.classname!="disabledhighlight") && (el.classname!="clear")) { if (menuhandler(el)) { cleanupmenu(menuactive) clearhighlight(menuactive) active=false lasthighlight=null } } } } } function getchildren(el) { var tlist = el.children.tags("table") var i = 0 while ((i<tlist.length) && (tlist[i].tagname!="table")) i++ if (i==tlist.length) return null else return tlist[i] } function domenudown(el) { if (el._childitem==null) el._childitem = getchildren(el) if ((el._childitem!=null) && (el.classname!="disabled") && (el.classname!="disabledhighlight")) { // performance optimization - cache child element ch = el._childitem if (ch.style.display=="block") { removehighlight(ch.active) return } ch.style.display = "block" if (el.classname=="root") { ch.style.pixeltop = el.offsetheight + el.offsettop + 2 ch.style.pixelleft = el.offsetleft + 1 if (ch.style.pixelwidth==0) ch.style.pixelwidth = ch.rows[0].offsetwidth+50 sinkmenu(el) active = true menuactive = el } else { childactive = el ch.style.pixeltop = getoffsetpos("top",el,"table") -3 // el.offsettop + el.offsetparent.offsettop - 3 ch.style.pixelleft = el.offsetleft + el.offsetwidth if (ch.style.pixelwidth==0) ch.style.pixelwidth = ch.offsetwidth+50 } } } function dohighlight(el) { el = getreal(el) if ("root"==el.classname) { if ((menuactive!=null) && (menuactive!=el)) { clearhighlight(menuactive) } if (!active) { raisemenu(el) } else sinkmenu(el) if ((active) && (menuactive!=el)) { cleanupmenu(menuactive) domenudown(el) } menuactive = el lasthighlight=null } else { if (childactive!=null) if (!childactive.contains(el)) closemenu(childactive, el) if (("td"==el.tagname) && ("clear"!=el.classname)) { var ch = getroottable(el) if (ch.active!=null) { if (ch.active!=el) { if (ch.active.classname=="disabledhighlight") ch.active.classname="disabled" else ch.active.classname="" } } ch.active = el lasthighlight = el if ((el.classname=="disabled") || (el.classname=="disabledhighlight") || (el.id=="break")) el.classname = "disabledhighlight" else { if (el.id!="break") { el.classname = "highlight" if (el._childitem==null) el._childitem = getchildren(el) if (el._childitem!=null) { domenudown(el) } } } } } } function removehighlight(el) { if (el!=null) if ((el.classname=="disabled") || (el.classname=="disabledhighlight")) el.classname="disabled" else el.classname="" } function cleanupmenu(el) { if (el==null) return for (var i = 0; i < el.all.length; i++) { var item = el.all[i] if (item.tagname=="table") item.style.display = "" removehighlight(item.active) item.active=null } } function closemenu(ch, el) { var start = ch while (ch.classname!="root") { ch = ch.parentelement if (((!ch.contains(el)) && (ch.classname!="root"))) { start=ch } } cleanupmenu(start) } function checkmenu() { if (document.all.menubar==null) return if ((!document.all.menubar.contains(event.srcelement)) && (menuactive!=null)) { clearhighlight(menuactive) closemenu(menuactive) active = false menuactive=null choiceactive = null } } function docheckout() { var el = event.toelement if ((!active) && (menuactive!=null) && (!menuactive.contains(el))) { clearhighlight(menuactive) menuactive=null } } function processkey() { if (active) { switch (event.keycode) { case 13: lasthighlight.click(); break; case 39: // right if ((lasthighlight==null) || (lasthighlight._childitem==null)) { var idx = menuactive.cellindex // if (idx==menuactive.offsetparent.cells.length-2) if (idx==getelement(menuactive,"tr").cells.length-2) idx = 0 else idx++ newitem = getelement(menuactive,"tr").cells[idx] } else { newitem = lasthighlight._childitem.rows[0].cells[0] } dohighlight(newitem) break; case 37: //left if ((lasthighlight==null) || (getelement(getroottable(lasthighlight),"tr").id=="menubar")) { var idx = menuactive.cellindex if (idx==0) idx = getelement(menuactive,"tr").cells.length-2 else idx-- newitem = getelement(menuactive,"tr").cells[idx] } else { newitem = getelement(lasthighlight,"tr") while (newitem.tagname!="td") newitem = newitem.parentelement } dohighlight(newitem) break; case 40: // down if (lasthighlight==null) { itemcell = menuactive._childitem curcell=0 currow = 0 } else { itemcell = getroottable(lasthighlight) if (lasthighlight.cellindex==getelement(lasthighlight,"tr").cells.length-1) { curcell = 0 currow = getelement(lasthighlight,"tr").rowindex+1 if (getelement(lasthighlight,"tr").rowindex==itemcell.rows.length-1) currow = 0 } else { curcell = lasthighlight.cellindex+1 currow = getelement(lasthighlight,"tr").rowindex } } dohighlight(itemcell.rows[currow].cells[curcell]) break; case 38: // up if (lasthighlight==null) { itemcell = menuactive._childitem currow = itemcell.rows.length-1 curcell= itemcell.rows[currow].cells.length-1 } else { itemcell = getroottable(lasthighlight) if (lasthighlight.cellindex==0) { currow = getelement(lasthighlight,"tr").rowindex-1 if (currow==-1) currow = itemcell.rows.length-1 curcell= itemcell.rows[currow].cells.length-1 } else { curcell = lasthighlight.cellindex - 1 currow = getelement(lasthighlight,"tr").rowindex } } dohighlight(itemcell.rows[currow].cells[curcell]) break; if (lasthighlight==null) { curcell = menuactive._childitem currow = curcell.rows.length-1 } else { curcell = getroottable(lasthighlight) if (getelement(lasthighlight,"tr").rowindex==0) currow = curcell.rows.length-1 else currow = getelement(lasthighlight,"tr").rowindex-1 } dohighlight(curcell.rows[currow].cells[0]) break; } } } function make_menu() { document.write("<table width='100%' cellpadding='0' cellspacing='0' border='0' style='background=rgb(212,208,200); background: buttonface; border-bottom: buttonshadow 1px solid; border-left: buttonhighlight 1px solid; border-right: buttonshadow 1px solid; border-top: buttonhighlight 1px solid;'>"); document.write("<tr><td><span class=handbtn></span></td><td>"); document.write("<table id=menubar onselectstart='return false' onclick='processclick()' onmouseover='dohighlight(event.toelement)' onmouseout='docheckout()' onkeydown='processkey()'><tr>"); j=1; while(eval("window.outbarfolder"+j)) j++; i=1; while(i<j) { folder=eval("outbarfolder"+i) document.write("<td nowrap class=root>"+folder[0]+"<table cellspacing=0 cellpadding=0>"); makeitems(folder); document.write("</table>"); i++; } document.write("</td></tr></table>"); document.write("</td><td width=100% onmouseover='processclick()'></td></tr></table>"); } function makeitems(folder) { var items=0; while(folder[items+1]) items+=5; items/=5; for(var i=1;i<items*5;i+=5) { /* if(folder[i+1]=="break") { document.write("<td nowrap id=break><hr></td>"); } else { document.write("<tr><td nowrap>"+folder[i+1]+"</td></tr>"); } */ document.write("<tr><td nowrap"+((folder[i+0]=="none")?"":" id='"+folder[i+0]+"'")+((folder[i+3]=="none")?"":" onclick=\"go(1,'"+folder[i+3]+"')\"")+">"+((folder[i+1]=="default")?"":"<font color="+folder[i+1]+">")+folder[i+2]+((folder[i+1]=="default")?"":"</font>")+"</td></tr>"); //alert("<tr><td nowrap "+((folder[i+0]=="none")?"":"id='"+folder[i+0]+"'")+((folder[i+3]=="none")?"":" onclick=go(1,'"+folder[i+3]+"')")+">"+((folder[i+1]=="default")?"":"<font color="+folder[i+1]+">")+folder[i+2]+((folder[i+1]=="default")?"":"</font>")+"</td></tr>"); } } function go(i,iurl) { switch (i) { case 1 : parent.location=iurl;break; //返回首页 case 2 : top.main.location='login.htm';break; //登录 case 3 : top.main.location='shenqing.htm';break; //注册 case 4 : top.main.location='addnew.asp';break; //增加新贴 case 5 : top.main.location='index1.asp';break; //第一页 case 6 : //上一页 var obj=top.main var str=obj.location.href; if(str.indexof("index1")>0) obj.location="index1.asp@page="+obj.document.all("ppage").value; else obj.location="index1.asp"; break; case 7 : //下一页 var obj=top.main var str=obj.location.href; if(str.indexof("index1")>0) obj.location="index1.asp@page="+obj.document.all("npage").value; else obj.location="index1.asp"; break; case 8 : //最后一页 var obj=top.main var str=obj.location.href; if(str.indexof("index1")>0) obj.location="index1.asp@page="+obj.document.all("epage").value; else obj.location="index1.asp"; break; case 9: top.main.location='editinfo.asp';break; case 10: top.main.location='quit.asp';break; case 11: top.main.location='userinfo.asp';break; case 12: var newwin=top.open("http://www.xinnew.com/"); newwin.focus(); break; } } make_menu(); </script> <script langguage="javascript" src="../http://www.xinnew.com/news2.js"></script> <br>