Script

本类阅读TOP10

·一个简单的javascript菜单
·网站流量统计代码
·可编辑的 HTML JavaScript 表格控件 DataGrid II
·JavaScript通用库(一)
·在网页中控制wmplayer播放器
·层遇到select框时
·TYPEING TEST ON LINE 在线打字测试 Free Software Javascript (aiiiq)
·javascript表单之间的数据传递!
·让网页自动穿上外套
·搜索gb2312汉字在网上的频率

分类导航
VC语言Delphi
VB语言ASP
PerlJava
Script数据库
其他语言游戏开发
文件格式网站制作
软件工程.NET开发
一个短小精悍使用的对象化QQ菜单

作者:未知 来源:月光软件站 加入时间:2005-2-28 月光软件站

这是我根据1000script上的QQ菜单自己该的一个对象化菜单,短小精悍,实用性强,我们所做的软件就用的这个。现在贡献出来,和大家共享:

<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>


//本程序版权归 zhjzh_zjz .代码可以随便传播。




相关文章

相关软件




月光软件程序下载编程文档电脑教程网站设计网址导航网络文学游戏天地幽默笑话生活休闲写作范文安妮宝贝
电脑技术编程开发网络专区谈天说地情感世界游戏元素分类游戏热门游戏体育运动手机专区业余爱好影视沙龙
音乐天地数码广场教育园地科学大观古今纵横谈股论金人文艺术医学保健动漫图酷二手专区地方风情各行各业

月光软件站·版权所有