我的漫漫程序之旅

          專注于JavaWeb開發
          隨筆 - 39, 文章 - 310, 評論 - 411, 引用 - 0
          數據加載中……

          超強的Javascript仿QQ導航菜單

          <html>
          <head>
          <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
          <title>仿QQ導航菜單</title>
          <style type="text/css">
          .titleStyle
          {
          background-color
          :#008800;color:#ffffff;border-top:1px solid #FFFFFF;font-size:9pt;cursor:hand;
          }

          .contentStyle
          {
          background-color
          :#eeffee;color:blue;font-size:9pt;
          }


          a
          {
          color
          :blue;
          }

          body
          {
          font-size
          :9pt;
          }

          </style>
          </head>
          <body>

          <script language="JavaScript">
          <!--
           
          var layerTop=20;       //菜單頂邊距
           var layerLeft=30;      //菜單左邊距
           var layerWidth=140;    //菜單總寬
           var titleHeight=20;    //標題欄高度
           var contentHeight=200//內容區高度
           var stepNo=10;         //移動步數,數值越大移動越慢

           
          var itemNo=0;runtimes=0;
           document.write('
          <span id=itemsLayer style="position:absolute;overflow:hidden;border:1px solid #008800;left:'+layerLeft+';top:'+layerTop+';width:'+layerWidth+';">');

           
          function addItem(itemTitle,itemContent){
             itemHTML
          ='<div id=item'+itemNo+' itemIndex='+itemNo+' style="position:relative;left:0;top:'+(-contentHeight*itemNo)+';width:'+layerWidth+';"><table width=100% cellspacing="0" cellpadding="0">'+
                 '
          <tr><td height='+titleHeight+' onclick=changeItem('+itemNo+') class="titleStyle" align=center>'+itemTitle+'</td></tr>'+
                 '
          <tr><td height='+contentHeight+' class="contentStyle">'+itemContent+'</td></tr></table></div>';
             document.write(itemHTML);
             itemNo
          ++;
           }

              
          //添加菜單標題和內容,可任意多項,注意格式:
           addItem('歡迎','<BR>歡迎光臨設計在線!');
           addItem('網頁陶吧','
          <center><a href="#">網頁工具</a> <BR><BR><a href="#">技術平臺</a> <BR><BR><a href="#">設計理念</a> <BR><BR><a href="#">更多</a></center>');
           addItem('美工教室','
          <center><a href="#">平面設計 </a> <BR><BR><a href="#">三維空間</a> <BR><BR><a href="#">設計基礎</a> <BR><BR><a href="#">更多..</a></center>');
           addItem('Flash','
          <center><a href="#">基礎教程</a> <BR><BR><a href="#">技巧運用</a> <BR><BR><a href="#">實例剖析</a> <BR><BR><a href="#">更多..</a></center>');
           addItem('多媒體','
          <center><a href="#">DIRECTOR</a> <BR><BR><a href="#">Authorware</a> <BR><BR><a href="#">更多..</a></center>');
           addItem('精品賞析','
          <center><a href="#">設計精品</a></center>');

           document.write('
          </span>')
           document.all.itemsLayer.style.height
          =itemNo*titleHeight+contentHeight;

           toItemIndex
          =itemNo-1;onItemIndex=itemNo-1;

           
          function changeItem(clickItemIndex){
             toItemIndex
          =clickItemIndex;
             
          if(toItemIndex-onItemIndex>0) moveUp(); else moveDown();
             runtimes
          ++;
             
          if(runtimes>=stepNo){
               onItemIndex
          =toItemIndex;
               runtimes
          =0;}

             
          else
               setTimeout(
          "changeItem(toItemIndex)",10);
           }


           
          function moveUp(){
             
          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>
          </body>
          </html> 


          posted on 2008-05-16 17:10 々上善若水々 閱讀(2024) 評論(1)  編輯  收藏 所屬分類: JavaScript

          評論

          # re: 超強的Javascript仿QQ導航菜單  回復  更多評論   

          你也是把效果圖貼出來看看呀!
          2008-05-19 08:49 | xingui5624
          主站蜘蛛池模板: 延川县| 承德县| 循化| 南城县| 汉川市| 宝坻区| 六盘水市| 巨野县| 无极县| 仙游县| 忻城县| 连南| 邯郸县| 青岛市| 许昌市| 仁化县| 揭西县| 盐津县| 宜宾市| 遵义市| 德庆县| 福州市| 绥中县| 和静县| 日喀则市| 开封县| 东丽区| 孝昌县| 鄂托克前旗| 重庆市| 石首市| 中超| 华坪县| 融水| 浑源县| 恩平市| 兴业县| 噶尔县| 祁门县| 北安市| 汨罗市|