[Javascript]一個類XP Explorer的菜單製作

來源:互聯網
上載者:User
製作一個類似XP的Explorer菜單,如下:


圖中所需有五個圖形: 

         

htm檔案源碼如下:如需要增加菜單,可簡單複製,但需要修改紅色的地方

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"

"http://www.w3.org/TR/html4/loose.dtd">

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=gb2312">

<title>一個類Explorer菜單</title>

<style type="text/css">

<!--

.Group {

 font-family: "宋體";

 font-size: 12px;

 background-image: url(images/center.gif);

 height: 22px;

}

.GroupLeft {

 background-image: url(images/left.gif);

 height: 22px;

 width:6px;

 background-repeat:no-repeat

}

.GroupRight {

 background-image: url(images/right.gif);

 height: 22px;

 width:6px;

 background-repeat:no-repeat

}

.MenuItem {

 font-family: "宋體";

 font-size: 12px; 

 cursor:hand;

}

-->

</style>

<script language="javascript">

var popUpWin=0;

function popUpWindow(URLStr, left, top, width, height)

{

  if(popUpWin)

  {

    if(!popUpWin.closed) popUpWin.close();

  }

  popUpWin = open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menub ar=no,scrollbar=no,resizable=no,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');

}

function messageWindow(title, msg)

{

  var width="300", height="125";

  var left = (screen.width/2) - width/2;

  var top = (screen.height/2) - height/2;

  var styleStr = 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbar=no,resizable=no,copyhistory=yes,width='+width+',height='+height+',left='+left+',top='+top+',screenX='+left+',screenY='+top;

  var msgWindow = window.open("","msgWindow", styleStr);

  var head = '<head><title>'+title+'</title></head>';

  var body = '<center>'+msg+'<br><p><form><input type="button" value="   Done   " onClick="self.close()"></form>';

  msgWindow.document.write(head + body);

}

function OpenMenu(MenuID)



 var obj = document.getElementById('Menu'+MenuID);

 var grpobj=document.getElementById('Group'+MenuID);

 current = (obj.style.display == 'none') ? '' : 'none';

 if(current=='none')

 {

   grpobj.src ='images/downarrows_white.gif';

 }

 else

   grpobj.src ='images/uparrows_white.gif';

 obj.style.display = current; 

}

</script>

</head>

<body>

<table width="150" border="0" cellpadding="0" cellspacing="0">

  <tr>

    <td class="GroupLeft"> </td>

    <td width="138" class="Group"> <table width="100%" height="100%"  border="0" cellpadding="0" cellspacing="0">

      <tr>

        <td width="85%" height="21" ondblclick="OpenMenu('1')">資料查詢</td>

        <td width="15%"><img src="images/uparrows_white.gif" width="16" height="16" id="Group1" onClick="OpenMenu('1')" style="cursor:hand"></td>

      </tr>

    </table></td>

    <td class="GroupRight"> </td>

  </tr >

  <tr id="Menu1" bgcolor="#F0F0F0">

    <td> </td>

    <td><div class="MenuItem">

  <li onMouseOver="this.style.color='#FF9933'" onMouseOut="this.style.color =''" onClick="messageWindow('Hello','Are you OK?')">查詢使用者</li>

        <li onMouseOver="this.style.color='#FF9933'" onMouseOut="this.style.color =''" onClick="popUpWindow('index.htm',0,0,800,600)">合約查詢</li>

        <li onMouseOver="this.style.color='#FF9933'" onMouseOut="this.style.color =''">預付款查詢</li>

        <li onMouseOver="this.style.color='#FF9933'" onMouseOut="this.style.color =''">發展人查詢</li>

        </div>

 </td>

    <td> </td>

  </tr>

  <tr>

    <td> </td>

    <td> </td>

    <td> </td>

  </tr>

</table>

</body>

</html>

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.