时间: 2021-07-31 作者:daque
<style type="text/css"> .titlestyle{ background-color:#6699cc;color:#ffffff; border-top:1px solid #ffffff;font-size:9pt;cursor:hand; } .contentstyle{ background-color:#efefef;color:blue;font-size:9pt; }</style></head><body><script language=javascript><!--
var mmenu=new array()
var headheight = 22;//每个题目的莫大var bodyheight = 260;//母体莫大var objcount = 6;//项手段个数,要变换了项手段个数别忘了该这个货色var step = 6;//挪动速率(请确认不妨被'bodyheight-headheight'整除,暂时的设定可选速率为1,2,3,6,23,138)var moving = false;//能否有挪动的名目var layertop=50; //菜单顶边距var layerleft=50; //菜单左边距var layerwidth=140; //菜单总宽窄var titleheight=20; //题目栏莫大var contentheight=200; //实质区莫大var stepno=1; //挪动步数,数值越大挪动越慢var itemno=0;
function regstermenu(menu){mmenu[mmenu.length]=menu;return mmenu.length-1;}
function mainmenu(img,capture,hrefurl){this.items=new array();this.img=img;this.capture=capture;this.hrefurl=hrefurl;this.id=regstermenu(this);}
//img 是动作图目标图像场所
//capture 是贯穿的笔墨
//href是超贯穿的地方
function submenu(img,capture,hrefurl){this.img=img;this.capture=capture;this.hrefurl=hrefurl;}
function addsub(item){this.items[this.items.length]=item;}
mainmenu.prototype.addsub=addsub;
function generatehtml(mmenu){var menuhtml="";menuhtml+="<span id=itemslayer style=\"position:absolute;overflow:hidden;border:1px solid #008800;left:'"+layerleft+"';top:'"+layertop+"';width:'"+layerwidth+"';\">"for(var i=0;i<mmenu.length;i++){menuhtml+="<div id=item"+i+" style=\"left: 0px; width: "+layerwidth+"; position: relative; top:-"+contentheight*i+"px\" itemindex=\""+i+"\"><table cellspacing=0 cellpadding=0 width=\"100%\"><tbody><tr><td class=titlestyle onclick=changeitem("+i+") align=middle height="+titleheight+">"+mmenu[i].capture+"</td></tr>"if(mmenu[i].items.length!=0){menuhtml+="<tr><td class=contentstyle height=200><div style=\"overflow:auto;height:200;\">" for(var q=0;q<mmenu[i].items.length;q++){menuhtml+="<br><center>"+mmenu[i].items[q].capture+"</center>"}menuhtml+="</div></td></tr>"}menuhtml+="</tbody></table></div>"}menuhtml+="</span>"return menuhtml;}
var mm1=new mainmenu('#','我的保藏夹','#');mm1.addsub(new submenu('#','文娱寰球','#'));mm1.addsub(new submenu('#','文娱寰球','#'));mm2=new mainmenu('#','我的保藏夹','#');mm2.addsub(new submenu('#','文娱寰球','#'));mm3=new mainmenu('#','我的保藏夹','#');mm3.addsub(new submenu('#','文娱寰球','#'));mm4=new mainmenu('#','我的保藏夹','#');mm4.addsub(new submenu('#','文娱寰球','#'));mm4.addsub(new submenu('#','文娱寰球','#'));
document.write (generatehtml(mmenu));document.all.itemslayer.style.height =mmenu.length*titleheight+contentheight;
//************************************************************
var toitemindex=mmenu.length-1; var onitemindex=mmenu.length-1; var runtimes=0; //"runtimes"用来记载层挪动度数 //菜单题目被点击时挪用这个因变量: function changeitem(clickitemindex){//myid.innertext=" "+itemslayer.outerhtml+" " //确定相映的层应上移仍旧下移: toitemindex=clickitemindex; if(toitemindex-onitemindex>0) moveup(); else movedown(); //确定的功夫间隙后连接挪动,直到移了设定的步数stepno: runtimes++; if(runtimes>=stepno){ onitemindex=toitemindex; runtimes=0;} else settimeout("changeitem(toitemindex)",10); } //相映菜单上移: function moveup(){ //确定应一道上移的菜单,并让它(们)历次挪动contentheight/stepno的隔绝: for(i=onitemindex+1;i<=toitemindex;i++) eval('document.all.item'+i+'.style.top=parseint(document.all.item'+i+'.style.top)-contentheight/stepno;'); } //相映菜单下移: function movedown(){ for(i=onitemindex;i>toitemindex;i--) eval('document.all.item'+i+'.style.top=parseint(document.all.item'+i+'.style.top)+contentheight/stepno;'); } //changeitem(0); //把第一个菜单动作默许表露
//************************************************************
//--></script>