代码封装完成啦
在这里谢谢大家对我的支持!
偶参照一些flash站点的菜单,
用javascript仿了一个,效果还是挺cool的.
简单地写一个使用说明:
第一步:实体化x-menu类
用法:
var .new coolmenucontrol()
第二步:建立菜单项目---
用法:
.insertmenu(类型,html代码,链接网址,目标)
类型:0代表菜单标题,1代表树型菜单子项目,2代表横向菜单子项目
html代码:显示在菜单上的html代码
链接网址:不用多说了,网址或javascript脚本
目标:默认为空,既不在本页打开;_blank代表在新的页面打开
例如:
coolmenu2.insertmenu(2, 新浪网,http://www.sina.com.cn/,_blank)
第三步:建立菜单---
用法:
.init(实体变量名,边框颜色,背景颜色,滑动速度,背景半透明度)
'实体变量名'必须与相同
如果背景颜色=transparent既为完全透明
例如:
coolmenu1.init(coolmenu1,#002000,#38ffff,0.1,15)
; document.write(suspendcode); var fcell=true for (i=0;i'+this.menuarray[i].value } else { inhtml+=' '+this.menuarray[i].value } fcell=true break; case 1: t=(cellcount-1)*2 if (t '+this.menuarray[i].value } else { inhtml+='
'+this.menuarray[i].value } fcell=true break; case 2: if (fcell) { inhtml+='
'+this.menuarray[i].value; fcell=false } else { inhtml+=' '+this.menuarray[i].value; } break; } } inhtml='' +'' +inhtml +'
'; //alert(inhtml) document.write(inhtml); this.lastscrollx=0; this.lastscrolly=-4; this.posxy(eval(this.menutable_name).cells[0]) this.td_w=eval(this.menutable_name).cells[0].scrollwidth+6 this.td_h=eval(this.menutable_name).cells[0].scrollheight setinterval(name+.scrollback(),1) } //-----单击超连接--- this.doclick=function(){ //alert(this.url) var url=this.href.split(,) //alert(url[0]) //alert(url[1]) if (url[0]==) return if (url[1]==_blank) {window.open(url[0])} else {location.href=url[0]} } //-----滑动处理--- this.scrollback=function(){ diffx=this.td_x-3 diffy=this.td_y-5 diffw=this.td_w diffh=this.td_h percentx=this.speed*(diffx-this.lastscrollx); percenty=this.speed*(diffy-this.lastscrolly); percentw=this.speed*(diffw-this.lastscrollw); percenth=this.speed*(diffh-this.lastscrollh); if(percentx>0)percentx=math.ceil(percentx); else percentx=math.floor(percentx); if(percenty>0)percenty=math.ceil(percenty); else percenty=math.floor(percenty); if(percentw>0)percentw=math.ceil(percentw); else percentw=math.floor(percentw); if(percenth>0)percenth=math.ceil(percenth); else percenth=math.floor(percenth); eval(this.hk_name).style.pixeltop+=percenty; eval(this.hk_name).style.pixelleft+=percentx; eval(this.hktable_name).style.pixelwidth+=percentw; eval(this.hktable_name).style.pixelheight+=percenth; this.lastscrollx=this.lastscrollx+percentx; this.lastscrolly=this.lastscrolly+percenty; this.lastscrollw=this.lastscrollw+percentw; this.lastscrollh=this.lastscrollh+percenth; } //-----滑出--- this.doover=function() { if (event.srcelement.tagname==td) { if (event.srcelement.innertext.length==0 || event.srcelement.innertext==|) return this.posxy(event.srcelement) this.td_w=event.srcelement.scrollwidth+6 this.td_h=event.srcelement.scrollheight } } //-----绝对定位--- this.posxy=function(obj){ hk_left=obj.offsetleft hk_top=obj.offsettop vparent = obj.offsetparent; while (vparent.tagname.touppercase() != body) { hk_left += vparent.offsetleft; hk_top += vparent.offsettop; vparent = vparent.offsetparent; } this.td_x=hk_left this.td_y=hk_top } //-----关于--- this.about=function(){ alert(ok) } }
[ctrl+a 全选 注:如需引入外部js需刷新才能执行]