`

动态删减选项卡的效果示例

    博客分类:
  • js
阅读更多
<html>
<head>
 <title>163邮箱选项卡效果</title>
 <script>
 </script>
 <style>
  ul,li
  {
   margin:0;
   padding:0;
   list-style:none;
   /*for close location*/
   position:relative; 
  }
  li
  {
   display:block;
   width:130px;
   height:25px;
   float:left;
   cursor:pointer;
   overflow:hidden;
  }
  span
  {
   font-size:10pt;
   color:#22b5d9;
   font-weight:bold;
   display:block;
  }
  #asgardCard li
  {
   font-size:10pt;
   font-weight:bold;
   color:#22b5d9;
   border:1px solid #22b5d9;
   margin:10px;
   text-align:center;
   line-height:1.5;
  }
 </style>
 
 <style>
  /*Asgard CardProgram Css Start*/
  #itemsPanel,#itemsPanel li
  {
   margin:0;
   padding:0;
   list-style:none;
   /*for close location*/
   position:relative; 
  }
  /*Clear Float:Referrence-->http://www.blueidea.com/tech/web/2005/3065.asp*/
  /*There is defect:the attribute-content hold one line place.*/
  ul:after
  {
      content: "."; 
      display: block;
      height: 0; 
      clear: both; 
      visibility: hidden;
  }
  #cardContent
  {
   height:auto;
   min-height:300px;
   border:2px solid #cccccc;
   clear:both;
  }
  #itemsPanel li
  {
   display:block;
   width:130px;
   height:25px;
   float:left;
   cursor:pointer;
   overflow:hidden;
  }
  #cardFrame
  {
   width:100%;height:100%;border:1px solid #ffffff;margin:0;
  }
  .active
  {   
   background:url('http://bbs.blueidea.com/attachments/2007/8/20/20070820_b3321ab700a7e293b3ceJODnkLUsGEhy.jpg') 0 0 no-repeat;
  }  
  .default
  {
   background:url('http://bbs.blueidea.com/attachments/2007/8/20/20070820_b3321ab700a7e293b3ceJODnkLUsGEhy.jpg') 0 -25px no-repeat;
  }
  .title
  {
   font-size:10pt;
   font-weight:bold;
   line-height:2;
   padding-left:10px;
   display:block;
   width:105px;
   height:25px;
  }
  li .close
  {   
   position:absolute;
   top:9px;
   left:115px;
   display:block;
   width:10px;
   height:10px;
   overflow:hidden;
  }
  .active .close
  {
   background:url('http://bbs.blueidea.com/attachments/2007/8/20/20070820_b3321ab700a7e293b3ceJODnkLUsGEhy.jpg') 0 -50px no-repeat;
  }
  .default .title
  {
   color:#999999;
  }
  .active .title
  {
   color:#000000;
  }
  .active .close:hover
  {
   background:url('http://bbs.blueidea.com/attachments/2007/8/20/20070820_b3321ab700a7e293b3ceJODnkLUsGEhy.jpg') -10px -50px no-repeat;
  }
  .default .close
  {
   background:url('http://bbs.blueidea.com/attachments/2007/8/20/20070820_b3321ab700a7e293b3ceJODnkLUsGEhy.jpg') -20px -50px no-repeat;
  }
  .default .close:hover
  {
   background:url('http://bbs.blueidea.com/attachments/2007/8/20/20070820_b3321ab700a7e293b3ceJODnkLUsGEhy.jpg') -30px -50px no-repeat;
  }
  /*Asgard CardProgram Css End*/
 </style>
</head>
<body>
<span>1.代码效果示例:</span>
<ul> 
 <li class="active">
  <nobr class="title">Kiss</nobr>
  <a href="#nogo" class="close" title="关闭"></a>
 </li>
 <li class="default">
  <nobr class="title">Andy</nobr>
  <a href="#nogo" class="close" title="关闭"></a>
 </li> 
</ul>
<p />
<span>注:以上代码为DOM动态组织的代码参考<span>
<p style="clear:both;"/>
<p />
<span>2.点击下表,更换内容</span>
<ul id="asgardCard">
<li title="blueidea">蓝色理想</li>
<li title="google">Google中国</li>
<li title="email126">Email-126</li>
<li title="ngacn">艾泽拉斯</li>
</ul>
<p style="clear:both;"/>
<span>3.以下为动态创建:</span>
<div>
 <ul id="itemsPanel">
 </ul>
 <div id="cardContent">
 <iframe id="cardFrame">
 </iframe>
 </div>
</div>
</body>
<script>
/*
* 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<this.register.length;i++)
 {
  if(this.register[i].element.id==id)
  {
   return true;
  }
 } 
 return false;
}
/*
*function:register visited sequence
*      type--add | delete | active
*/
Asgard.CardProgram.ItemsPanel.prototype.visitedRegister=function(item,type)
{
 var i=this.register.length;
 if(type=="add")
 {  
  for(var k=0;k<i;k++)
  {
   this.register[k].resetItem();
  }
  this.currentItem=item;
  this.register[i]=item;
  this.currentItem.element.className="active";
  
  this.changeSubPage();
 }
 else if(type=="delete")
 {     
  for(k=0;k<i;k++)
  {
   if(this.register[k]==item)
   {
    this.register.splice(k,1);
    break;
   }
  }
  if(item==this.currentItem)
  {
   i=this.register.length;
   if(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<i;k++)
   {
    if(this.register[k]==item)
    {
     this.register.splice(k,1);
     break;
    }
   }
   
   i=this.register.length;
   for(k=0;k<i;k++)
   {
    this.register[k].resetItem();
   }
   this.currentItem=item;
   this.register.push(item);
  }
  
  this.changeSubPage();
 }
}
/*
*function:define Object Item
*/
Asgard.CardProgram.Item=function(id,title,url,flag)
{ 
 this.element=this.$C();
 this.panel={};
 this.id=id;
 this.title=title;
 this.url=url;
 this.flag=flag;
 this.init();
};
/*
*function:init item
*/
Asgard.CardProgram.Item.prototype.init=function()
{
 this.element.setAttribute('id',this.id);
 this.element.className="default";  
 
 var mirror=this;
 if(!this.flag)
 {  
  this.element.innerHTML="<nobr class='title' title='"+this.title+"'>"+this.title+"</nobr>"+"<a href='#nogo' class='close' title='关闭'></a>";  
  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="<nobr class='title' title='"+this.title+"'>"+this.title+"</nobr>"; 
  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>
<script>
function attachExampleEvent()
{
 var lists=$('asgardCard').getElementsByTagName('li');
 for(var i=0;i<lists.length;i++)
 {
  lists[i].onclick=exampleClickListener;
 }
}
function exampleClickListener(e)
{
 e=e || window.event;
 var source=e.target || e.srcElement;
 if(source.getAttribute('title')=='blueidea')
 {
   itemsPanel.addItem(new Asgard.CardProgram.Item("blueidea","蓝色理想","http://www.blueidea.com",false));
 }
 else if(source.getAttribute('title')=='google')
 {
   itemsPanel.addItem(new Asgard.CardProgram.Item("google","Google中国","http://www.google.cn",false));
 }
 else if(source.getAttribute('title')=='email126')
 {
   itemsPanel.addItem(new Asgard.CardProgram.Item("email126","Email-126","http://mail.126.com",false));
 }
 else if(source.getAttribute('title')=='ngacn')
 {
   itemsPanel.addItem(new Asgard.CardProgram.Item("ngacn","艾泽拉斯","http://www.ngacn.com",false));
 } 
}
var itemsPanel=null;
function exampleStartMethod()
{
 attachExampleEvent();
 if(itemsPanel==null)
  itemsPanel=new Asgard.CardProgram.ItemsPanel("itemsPanel","cardFrame");
 itemsPanel.addItem(new Asgard.CardProgram.Item("index","时空创意","http://www.skst.com.cn",true)); 
}
window.onload=exampleStartMethod;
</script>
</html>
<a href="http://js.alixixi.com/">欢迎访问阿里西西网页特效代码站,js.alixixi.com</a>

 

 

效果:



 

 

来自:http://www.alixixi.com/Dev/HTML/jsrun/color/2008/2008051280191.html

  • 大小: 137.8 KB
分享到:
评论

相关推荐

    选项卡自动生成代码(html,js)

    选项卡自动生成代码,动态删减选项卡的效果示例

    实现表格/表单动态删减功能,以及实现粘贴excle表格数据,即可自动解析成每行数据

    实现表格/表单动态删减功能,以及实现粘贴excle表格数据,即可自动解析成每行数据

    WPF菜单栏,工具栏,TabControl动态添加、删除(支持左右滑动,选择),标题栏可修改背景色

    在本文中,我们将深入探讨如何在WPF(Windows Presentation Foundation)环境中实现动态的菜单栏、工具栏、TabControl的添加和删除功能,同时提供标题栏背景色的自定义修改。WPF是.NET Framework的一个重要组成部分...

    Android动态删减ListView,类似学习经历增删,钉钉物品领用

    在许多应用中,如钉钉的物品领用功能或网页上的教育经历展示,我们经常需要实现动态增删功能,即用户可以添加新的条目,也可以删除已有的条目,而列表的其他元素会相应地自动调整位置。这个过程需要对ListView的使用...

    凯立德地图删减程序

    凯立德地图删减程序 可以把不需要的地方地图删除。减少空间

    jquery动态增加删减表格行特效

    ### jQuery 动态增加删减表格行特效知识点详解 #### 一、背景介绍 在Web开发中,动态地增加或删除表格行是一项常见的需求。这种功能不仅能够提高用户体验,还能根据用户的需求灵活调整数据展示方式。jQuery作为一种...

    js实现input框文字动态变换显示效果

    本文实例讲述了js实现input框文字动态变换显示效果。分享给大家供大家参考。具体如下: 这里演示js实现INPUT框中的特殊显示效果,一些文字慢慢交替显示,最终显示出完整的文字,需要显示的文字预先保存在数组中,...

    Osisoft PI的API应用--位号删减

    **三、参考代码示例** 在提供的文件列表中,`piapi32.bas`可能包含了PI API的VB绑定库,而`PIDelete.exe`和`PIDelete_Main.frm`等可能是VB编译后的可执行程序和窗体文件,用于实现位号删除功能。具体代码如下(简化...

    ios-collectionviewcell重排序和删减,带动画效果.zip

    collectionviewcell重排序和删减,可以拖动排序,并且可以在拖动到顶部和底部时可以滚动。源码地址:https://github.com/wxp2012/XPCollectionViewCellsSort

    Unity Android 之 Unity Android 交互(aar形式)动态申请权限功能实现(权限可人为怎加删减,并含代码工程)

    Unity Android 之 Unity Android 交互(aar形式)动态申请权限功能实现(权限可人为怎加删减,并含代码工程) 1、Unity Android aar 包交互,实现动态权限申请 2、Unity 端可以根据需要添加自己的权限申请 3、权限有...

    C#OA三层架构示例代码

    【C# OA 三层架构示例代码】是一个用于展示企业级应用中常见设计模式的代码库,主要关注C#编程语言在开发办公自动化(Office Automation,简称OA)系统时采用的分层架构。这种架构模式通常包括表现层(Presentation ...

    EasyUI增查改删操作示例

    这个"EasyUI增查改删操作示例"提供了一套完整的实践教程,旨在帮助初学者快速掌握如何使用 EasyUI 实现数据管理中的基本功能:增加、查询、修改和删除(通常称为CRUD操作)。在C#编程环境中,这些操作通常与后端...

    c# tablelayoutpanel 动态增加和删除列 已测试通过 动态合并单元格 动态添加控件

    `.suo`文件存储了用户特定的Visual Studio选项;而`WindowsFormsApplication1`可能包含了实际的项目源代码,其中包括实现上述功能的C#代码。 总之,`TableLayoutPanel`的动态管理能力使得开发者能够构建更灵活的...

    (高清无删减)Power BI 官方中文教程.pdf

    - **销售和市场营销示例**:提供分析市场活动效果的方法。 - **供应商质量分析示例**:介绍如何监控和改善供应商性能。 #### 概念 - **最新Power BI Desktop更新中有哪些新增功能?**:列举最新版本中加入的新特性...

    开源TeamTalk(mogutt)_2015年5月前原版未删减代码

    2015年5月前的原版未删减代码意味着我们可以深入研究其早期的设计理念和技术实现,这对于学习和理解即时通讯系统的开发具有很高的价值。 在开源TeamTalk(mogutt)的代码中,我们可以探索以下几个关键知识点: 1. **...

    matplotlib删减后安装

    这个“matplotlib删减后安装”指的是针对特定项目需求进行的精简版安装,可能是为了减少不必要的依赖和优化项目的体积。 在Python环境中安装`matplotlib`,通常使用`pip`工具,命令如下: ```bash pip install ...

    删减与更改.docx

    考虑到技术可行性,我们需要评估表格的复杂性,如是否需要公式计算、图表生成、动态更新等。 关于将【吨钢综合能耗】改为【重量箱综合能耗】,这可能是根据业务需求或标准变化进行的调整。在Word中,修改此内容非常...

    不健全关系删减部分(1234567890).zip

    很抱歉,根据您提供的信息,"不健全关系删减部分(1234567890).zip"这个文件标题和描述似乎并不包含任何明显的IT知识点。标题可能是指某种数据或内容的筛选、修改或删除过程,但没有具体到IT技术的细节。标签为空,...

Global site tag (gtag.js) - Google Analytics