懂视1
懂视101
懂视201
懂视301
懂视401
懂视501
懂视601
懂视701
懂视801
懂视901
懂视1001
懂视1101
懂视1201
懂视1301
懂视1401
懂视1501
懂视1601
懂视1701
懂视1801
懂视1901
文库1
文库101
文库201
文库301
文库401
文库501
文库601
文库701
文库801
文库901
文库1001
文库1101
文库1201
文库1301
文库1401
文库1501
文库1601
文库1701
文库1801
文库1901
懂式情感网
全部频道
首页
科技
教育
生活
旅游
时尚
美容
美食
健康
体育
游戏
汽车
家电
您的当前位置:
首页
发一个比较漂亮的选项卡动态增删的效果_导航菜单
发一个比较漂亮的选项卡动态增删的效果_导航菜单
来源:懂式情感网
先放个图片,我改下代码。
163邮箱选项卡效果
script> 1.代码效果示例:
Kiss
Andy
注:以上代码为DOM动态组织的代码参考
2.点击下表,更换内容
蓝色理想
Google中国
Email-126
艾泽拉斯
3.以下为动态创建: /* * Field Declare ^-^ */ var Asgard; if(!Asgard) Asgard={}; if(!Asgard.CardProgram) Asgard.CardProgram={}; /* *function:define Object ItemsPanel */ Asgard.CardProgram.ItemsPanel=function(id,frameId) { this.element=$(id); this.register=new Array(); this.currentItem=null; this.cardFrame=$(frameId); this.element.className='itemsPanel'; } /* *function:add item from panel */ Asgard.CardProgram.ItemsPanel.prototype.addItem=function(item) { if(this.validateExist(item.element.getAttribute('id'))) return; item.panel=this; this.visitedRegister(item,"add"); this.element.appendChild(item.element); } /* *function:delete item from panel */ Asgard.CardProgram.ItemsPanel.prototype.deleteItem=function(item) { this.visitedRegister(item,"delete"); this.element.removeChild(item.element); } /* *Ajax or other */ Asgard.CardProgram.ItemsPanel.prototype.changeSubPage=function() { if(this.register.length==0) { this.cardFrame.src=""; return; } this.cardFrame.src=this.currentItem.url; /* *这里用户可以自己定义想要的页面,如果你想内嵌IFrame。 */ } Asgard.CardProgram.ItemsPanel.prototype.validateExist=function(id) { for(var i=0;i
0) { this.currentItem=this.register[i-1]; this.currentItem.element.className="active"; } else this.currentItem=null; } this.changeSubPage(); } else if(type=="active") { if(this.currentItem==item) return; else { for(k=0;k
"+this.title+""+""; this.addEventListener(this.$ES(this.element,'nobr')[0],'click',function(){mirror.activeItem();}); this.addEventListener(this.$ES(this.element,'a')[0],'click',function(){mirror.destroyItem();}); } else { this.element.innerHTML="
"+this.title+"
"; this.addEventListener(this.$ES(this.element,'nobr')[0],'click',function(){mirror.activeItem();}); } } /* *active item */ Asgard.CardProgram.Item.prototype.activeItem=function() { this.panel.visitedRegister(this,"active"); this.element.className="active"; } /* *function:reset item */ Asgard.CardProgram.Item.prototype.resetItem=function() { this.element.className="default"; } /* *function:destroy item */ Asgard.CardProgram.Item.prototype.destroyItem=function() { this.panel.deleteItem(this); } /* *function:addListener to item */ Asgard.CardProgram.Item.prototype.addEventListener=function(element,type,handler) { if(element.addEventListener) element.addEventListener(type,handler,true); else element.attachEvent("on"+type,handler,true); } /* *function:usefull functions */ Asgard.CardProgram.Item.prototype.$C=function(tag) { if(tag && typeof tag =="string") return document.createElement(tag); else return document.createElement('li'); } Asgard.CardProgram.Item.prototype.$ES=function(element,tag) { return element.getElementsByTagName(tag); } function $(id) { return document.getElementById(id); } script> function attachExampleEvent() { var lists=$('asgardCard').getElementsByTagName('li'); for(var i=0;i
[Ctrl+A 全选 注:如需引入外部Js需刷新才能执行]
代码说明
1.我的CSS分割为2段了,第一段为此演视用,可自己定制,第二段为此框架必须。
2.script我也分割为2段,第一段为必须,第二段为客户定制的,我这里的代码是给一个实现参考。
3.以下的HTML代码为参考实现的必须容器代码
代码如下:
使用介绍:
1.ItemsPanel对象
构造方法:new Asgard.CardProgram.ItemsPanel("itemsPanel","cardFrame").
接受的2个参数,第一个为ul容器ID,第二个为我们需要展现标签对应的内容的irame的ID 。
ItemPanel对象使用addItem方法添加Item。
如果你需要创建多个ItemsPanel,可以自己参考我的范例来进行。
2.Item对象
构造方法:new Asgard.CardProgram.Item("index","时空创意","http://www.skst.com.cn",true)接受4个参数
第一个为打算创建的选项卡的id,第二个为打算创建的选项卡的标题,第三个为此选项卡对应的URL,第四个为是否为首页,因为我们也许会打算创建一个默认页面不允许关闭。当然如果你全部设置为true,那么也就是正常的选项卡效果了。
显示全文