人人做人人澡人人爽欧美,国产主播一区二区,久久久精品五月天,羞羞视频在线观看免费

當(dāng)前位置:蘿卜系統(tǒng)下載站 > 技術(shù)開發(fā)教程 > 詳細(xì)頁面

一個(gè)容易的javascript菜單

一個(gè)容易的javascript菜單

更新時(shí)間:2020-12-07 文章作者:未知 信息來源:網(wǎng)絡(luò) 閱讀次數(shù):

 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>AgetimeMenu Demo</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style>
 .agetime_bar{
  position:absolute;top:0px;left:0px;height:22px;width:100%;border:1px outset;background-color:RGB(212,208,200);z-index:98;
 }
 .agetime_barItem{
  width:60px;height:20px;border:1px solid RGB(212,208,200);text-align:left;padding-left:10px;
  background:RGB(212,208,200);color:#000000;font-size:9pt;
 }
 .agetime_barItemDown{
  width:60px;height:20px;border:1px inset RGB(212,208,200);text-align:left;padding-left:10px;
  background:#F0F0F0;color:#000000;font-size:9pt;
 }
 .agetime_barItemHover{
  width:60px;height:20px;border:1 outset;text-align:left;padding-left:10px;
  background:#F0F0F0;color:#000000;font-size:9pt;
 }
 .agetime_pad{
  cursor:default;font-size:9pt;width:100%;
 }
 .agetime_padItem{
  width:100%;height:18px;border:1px solid RGB(212,208,200);text-align:left;padding-left:10px;
  background:RGB(212,208,200);color:#000000;font-size:9pt;
 }
 .agetime_padItemFalse{
  padding-left:10px;font-size:9pt; color:#808080;
 }
 .agetime_padItemFalseHover{
  padding-left:10px;font-size:9pt; color:#808080;background-color:#333366;
 }
 .agetime_padItemHover{
  width:100%;height:18px;text-align:left;padding-left:10px;
  background-color:#333366;color:#FFFFFF;font-size:9pt;
 }
 .agetime_padItemDown{
  width:100%;height:18px;text-align:left;padding-left:10px;border:1px inset;
  background-color:#9999CC;color:#FFFFFF;font-size:9pt;
 }
 .agetime_hr{
  border:1px inset;
 }
 .agetime_board{
  background-color:RGB(212,208,200);border:2px outset;
 }
</style>
</head>
<body>
<script language="javascript">
 var menu = agetimeMenu("agetime",
  [
   [
    ["文件",null,null,true,"打開文件"],  //顯示文字,方法,命令,狀態(tài),狀欄顯示文字
    ["打開",null,null,false,"打開文件"],
    ["--"],
    ["你好","js","alert('Hello')",true,"一聲問候"],
    ["新窗口","ABC","about:blank",true,"彈出ABC窗口"],
    ["空白",null,"about:blank",true,"在當(dāng)前窗口顯示空白頁"]
   ],
   [
    ["編輯",null,null,false,"打開文件"],
    ["撤消",null,null,true,"打開文件"],
    ["重做",null,null,true,"打開文件"]
   ],
   [
    ["文件","js","alert('無子菜單')",true,"打開文件"]
   ]
  ]
 );
 //方法為"js"時(shí),命令則為javascript語句,為非"js"值時(shí),命令則是一個(gè)URL,而打開這個(gè)URL的目標(biāo)位置則是方法所指定的窗口;
 //["你好","js","alert('Hello'),true,"一聲問候"];
 //顯示文字為"--"是按鈕是一個(gè)分隔符;

 function agetimeMenu(id,array){
  var menu=this;
  menu.pad=null;     //裝載各個(gè)子菜單
  menu.barItems=[];    //菜單條的各位按鈕
  menu.pads=[];     //每個(gè)子菜單為一個(gè)table存放于menu.pad上;
  menu.selectedIndex=-1;  //菜單條選中按鈕的索引值
  menu.board=null;    //子菜單面板

  //建立菜單條
  this.crtMenuBar=function(){
   var len=array.length;
   menu.bar = document.body.appendChild(document.createElement('div'));
   menu.bar.className=id+"_bar";
   for(var i=0;i<len;i++){
    menu.barItems[i]=menu.addMenuBarItem(array[i][0],i);
    menu.addMenuPad(array[i],i);
   }
  }

  //子菜單
  this.addMenuPad=function(ary,index){
   var len=ary.length;
   var pad=menu.crtElement("table",menu.pad);
   pad.cellSpacing=1;  pad.cellPadding=0;
   pad.className=id+"_pad";
   pad.style.display="none";
   for(var i=1;i<len;i++){
    var Row=pad.insertRow(i-1);
    menu.addMenuPadItem(ary[i],Row);
   }
   menu.pads[index]=pad;
  }

  //各子菜單按鈕
  this.addMenuPadItem=function(ary,Row){
    var Cell=Row.insertCell(0);
    if(ary[0]!="--"){
     Cell.innerText=ary[0];
     if(ary[3]){  //有效狀態(tài);
      Cell.className=id+"_padItem";
      Cell.onmouseover=function(){
       Cell.className=id+"_padItemHover";
       window.status=ary[4];
      }
      Cell.onmouseout=function(){
       Cell.className=id+"_padItem";
       window.status="";
      }
      Cell.onmousedown=function(){ Cell.className=id+"_padItemDown"; }
      Cell.onmouseup=function(){
       Cell.className=id+"_padItemHover";
       menu.hideMenu();
       menu.execute(ary);
      }
     }
     else{  //按鈕無效;
      Cell.className=id+"_padItemFalse";
      Cell.onmouseover=function(){
       Cell.className=id+"_padItemFalseHover";
       window.status=ary[4];
      }
      Cell.onmouseout=function(){
       Cell.className=id+"_padItemFalse";
       window.status="";
      }
     }
    }
    else{
     var hr=menu.crtElement("hr",Cell);
     hr.className=id+"_hr";
    }
    Cell.onclick=function(){
     event.cancelBubble=true;
    }
  }

   //菜單條的按鈕
  this.addMenuBarItem=function(ary,index){
   var item=menu.crtElement("button",menu.bar);
   item.value=ary[0];
   item.disabled=!ary[3];
   item.className=id+"_barItem";
   item.onmouseover=function(){
    if(menu.selectedIndex==-1){
     item.className=id+"_barItemHover";
    }
    else{
     menu.barItems[selectedIndex].className=id+"_barItem";
     item.className=id+"_barItemDown";
     menu.showMenu(index);
    }
    window.status=ary[4];
   }
   item.onmouseout=function(){
    if(menu.selectedIndex==-1)  item.className=id+"_barItem";
    window.status="";
   }
   item.onclick=function(){
    event.cancelBubble=true;
    if(menu.selectedIndex==-1){
     item.className=id+"_barItemDown";
     menu.showMenu(index);
    }
    else{
     menu.hideMenu();
     item.className=id+"_barItemHover";
    }
    menu.execute(ary);
    item.blur();
   }
   return item;
  }

  //顯示子菜單
  this.showMenu=function(index){
   if(menu.selectedIndex!=-1) menu.pads[selectedIndex].style.display="none";
   menu.board.style.pixelLeft=menu.barItems[index].offsetLeft+2;
   //menu.board.style.pixelHeight="";
   if(menu.pads[index].rows.length>0) menu.board.style.display="";
   else menu.board.style.display="none";
   menu.pads[index].style.display="";
   menu.selectedIndex=index;
  }
   //隱藏子菜單
  this.hideMenu=function(){
   if(menu.selectedIndex==-1) return;
   menu.barItems[menu.selectedIndex].className=id+"_barItem";
   menu.pads[selectedIndex].style.display="none";
   menu.selectedIndex=-1;
   menu.board.style.display="none";
  }

  //執(zhí)行菜單命令;
  this.execute=function(ary){
   if(ary[2]==null) return;
   if(ary[1]=="js") { eval(ary[2]); menu.hideMenu(); }
   else if(ary[1]==null || ary[1].toLowerCase=="_self") location.href=ary[2];
   else{ var x=window.open(ary[2],ary[1]); x.focus(); }
  }

  //建立子菜單的顯示面板
  this.crtMenuBoard=function(){
   document.write(
    "<div id='"+id+"_board' style='position:absolute;width:160px;height:10px;left:0px;top:20px;background-color:#666666;z-index:99;display:none;'>"+
     "<div style='position:absolute;width:100%;height:100%;left:0px;top:0px;'>"+
      "<iframe id='"+id+"_frame' name='"+id+"_frame' width='100%' height='100%' frameborder='0' scrolling='no'></iframe>"+
     "</div>"+
     "<div id='"+id+"_pad' style='position:absolute;width:100%;height:100%;left:0px;top:0px;'></div>"+
    "</div>"
   );
   menu.board=document.getElementById(id+"_board");
   menu.pad=document.getElementById(id+"_pad");
   menu.pad.className=id+"_board";
   menu.pad.onselectstart=function(){ return false;}
  }

  //增加對(duì)像的一個(gè)子元素
  this.crtElement=function(el,p){
   return p.appendChild(document.createElement(el));
  }

  //安裝菜單;
  this.setup=function(){
   menu.crtMenuBoard();
   menu.crtMenuBar();
   document.attachEvent("onclick",menu.hideMenu);
  }

  menu.setup();
 }
</script>
</body>
</html>

溫馨提示:喜歡本站的話,請(qǐng)收藏一下本站!

本類教程下載

系統(tǒng)下載排行

網(wǎng)站地圖xml | 網(wǎng)站地圖html
主站蜘蛛池模板: 饶平县| 雅安市| 鹤庆县| 得荣县| 苍南县| 成都市| 资阳市| 兴海县| 滦平县| SHOW| 宁南县| 九寨沟县| 新昌县| 密云县| 千阳县| 湖北省| 凌源市| 石渠县| 婺源县| 聂拉木县| 黄梅县| 香港| 奉新县| 元朗区| 兰西县| 江陵县| 安远县| 易门县| 江油市| 广安市| 仁寿县| 樟树市| 阿城市| 安塞县| 汕尾市| 凤山县| 平阴县| 平湖市| 仪陇县| 盘锦市| 固原市|