js模仿flash菜单-- 超酷

<script>
var CHeight
var lastHeight
var lastDiv=null
var speed=.25
var Cid=null
var Menu=Array()
var ST=null
var MaxH=52
var MinH=28
Menu[0]=new menuText("Home","回到主页")
Menu[1]=new menuText("Download","下载")
Menu[2]=new menuText("Suport","技术支持")
Menu[3]=new menuText("Blog","[url]http://puterjam.vipx.net</a>")
Menu[4]=new menuText("BlueIdea","BlueIdea经典论坛")
Menu[5]=new menuText("Help","这是我第二个用JS写的仿Flash菜单")
Menu[6]=new menuText("Test","你死了我很小气的")

function menuText(Title,content)
{
this.title=Title
this.content=content
}

function ChangeHeight(){

if (treediv.length)
{
for (i=0;i<treediv.length;i++){
  diffH=CHeight[i]
  pH=(speed)*(diffH-lastHeight[i]);
  if(pH>0)pH=Math.ceil(pH);
    else pH=Math.floor(pH);
  treediv[i].style.pixelHeight+=pH;
  lastHeight[i]=lastHeight[i]+pH;
  }
}
else
{
  diffH=CHeight
  pH=(speed)*(diffH-lastHeight);
  if(pH>0)pH=Math.ceil(pH);
    else pH=Math.floor(pH);
  treediv.style.pixelHeight+=pH;
  lastHeight=lastHeight+pH;
}

}

function DivOver(id,obj){
divitem=event.srcElement
if (treediv.length) {CHeight[id]=MaxH;Cid=id}else {CHeight=MaxH;Cid=0}
divitem.style.backgroundColor="#007500";
divitem.style.fontSize="14px";
ST=window.setTimeout("show()",160)
}

function DivOut(id,obj){
divitem=event.srcElement
if (treediv.length) CHeight[id]=MinH;else CHeight=MinH;
divitem.style.backgroundColor="#00aa00"
divitem.style.fontSize="12px"
if (Cid!=null)
  {
  if (treediv.length) treediv[Cid].innerHTML=Menu[Cid].title;else treediv.innerHTML=Menu[Cid].title;
  }
if (ST!=null) window.clearTimeout(ST)
if (treediv.length)
  {if (treediv[Cid].filters[0]) {treediv[Cid].filters[0].stop();treediv[Cid].style.filter=""}}
  else
  {if (treediv.filters[0]) {treediv.filters[0].stop();treediv.style.filter=""}}
}

function show(){
if (treediv.length)
{
  treediv[Cid].style.filter="blendtrans(duration=.1)"
  treediv[Cid].filters[0].apply();
  treediv[Cid].innerHTML=Menu[Cid].title+"<br>     "+Menu[Cid].content
  treediv[Cid].filters[0].play();
  }
  else
  {
  treediv.style.filter="blendtrans(duration=.1)"
  treediv.filters[0].apply();
  treediv.innerHTML=Menu[Cid].title+"<br>     "+Menu[Cid].content
  treediv.filters[0].play();  
  }
}

function init()
{
if (treediv.length)
{
CHeight=new Array()
lastHeight=new Array()
for (i=0;i<treediv.length;i++){
  CHeight[i]=0
  lastHeight[i]=0
  treediv[i].innerHTML=Menu[i].title
  }
}
else
{
  CHeight=0
  lastHeight=0
  treediv.innerHTML=Menu[0].title
}
DivTD.style.pixelHeight=DivTD.scrollHeight+(MaxH-MinH)+4
setInterval("ChangeHeight()",1)
}

 

</script>
<style>
.divcss{
font-size:12px;
background-color:00aa00;
border-bottom:1px solid #ffffff;
padding:6px;
padding-left:15px;
color:#ffffff;
font-family:Arial;
cursor:hand;
line-height:130%;
font-weight:bold;

}
.dh{
font-size:12px;
border-bottom:1px solid #ffffff;
padding:12px;
color:#ffffff;
font-family:Arial;
cursor:default;
}
a{
font-size:12px;
color:#FFFFFF;
text-decoration:none;
}
a:hover{
font-size:12px;
color:#FFFFFF;
text-decoration:none;
}
a.a1:hover{
font-size:12px;
color:#FFFFFF;
text-decoration:underline;
}
.content{
font-size:12px;
font-weight:400;
}
</style>
<body οnlοad=init() bgcolor="#cccccc">
    <div align="center">
    <table border="0" width="350" cellpadding=0 cellspacing=0 style="border:3px solid #ffffff;background-color:#009500;">
        <tr>
          <td valign="top" id=DivTD background=#009500>
              <a href="[url]http://puterjam.vipx.net</a>"><div class=divcss id="treediv" οnmοuseοver="DivOver(0,this)" οnmοuseοut="DivOut(0,this)"></div></a>
              <a href="javascript:alert('下载')"><div class=divcss id="treediv" οnmοuseοver="DivOver(1,this)" οnmοuseοut="DivOut(1,this)"></div></a>
              <a href="[url]http://moodboy.com/puterjam/blog/blogview.asp?logID=66</a>" target=_blank><div class=divcss id="treediv" οnmοuseοver="DivOver(2,this)" οnmοuseοut="DivOut(2,this)"></div></a>
              <a href="[url]http://puterjam.vipx.net</a>" target=_blank><div class=divcss id="treediv" οnmοuseοver="DivOver(3,this)" οnmοuseοut="DivOut(3,this)"></div></a>
              <a href="[url]http://www.blueidea.com/bbs</a>" target=_blank><div class=divcss id="treediv" οnmοuseοver="DivOver(4,this)" οnmοuseοut="DivOut(4,this)"></div></a>
              <a href="javascript:alert('欢迎使用!')"><div class=divcss id="treediv" οnmοuseοver="DivOver(5,this)" οnmοuseοut="DivOut(5,this)"></div></a>                      
              <a href="javascript:alert('转载请注明出处:PuterJam/'s Blog')"><div class=divcss id="treediv" οnmοuseοver="DivOver(6,this)" οnmοuseοut="DivOut(6,this)"></div></a>
              <div style="FILTER: progid:DXImageTransform.Microsoft.Gradient(gradientType=0,startColorStr=#007500,endColorStr=#009500);height:6px;overflow:hidden"></div>
          </td>
    <tr>
    <td><div class=dh align=center><b>JS Menu Made by
        <a href="[url]http://puterjam.vipx.net</a>" class=a1>PuterJam</a></b></div></td>
    </tr>          
    </table>

    </div>

</body>
 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值