實現Web頁面上的右鍵捷徑功能表

來源:互聯網
上載者:User
web|菜單|頁面|右鍵

樣式代碼:

<style type="text/css">
   body{font: 9pt "宋體"; margintop: 0px ; color: red; background: #ffffff}
   a.{ font: 9pt "宋體"; cursor: hand; font-size: 9pt ; color: blue; text-decoration: none }
   a:active{ font: 9pt "宋體"; cursor: hand; color: #FF0033 }
   a.cc:hover{ font: 9pt "宋體"; cursor: hand; color: #FF0033}
   .box{ font: 9pt "宋體"; position: absolute; background: LightGrey; }
  </style>

html代碼如下:

  <table id="itemopen" class="box" style="DISPLAY:none">
   <tr>
    <td>快顯功能表</td>
   </tr>
   <tr>
    <td><a href="http://blog.csdn.net/Erickson/" class="cc">Erickson的專欄</a></td>
   </tr>
   <tr>
    <td><a href="http://www.csdn.net" class="cc">CSDN</a></td>
   </tr>
   <tr>
    <td><a href="http://www.google.com" class="cc">Google 搜尋</a></td>
   </tr>
   <tr>
    <td><a href="http://www.sohu.com" class="cc">搜狐</a></td>
   </tr>
   <tr>
    <td><a href="http://www.yahoo.com" class="cc">Yahoo</a></td>
   </tr>
   <tr>
    <td><a href="http://www.163.com" class="cc">163 網站</a></td>
   </tr>
   <tr>
    <td><a href="http://sports.sina.com.cn" class="cc">新浪網體育</a></td>
   </tr>
   </table>

指令碼代碼:

右擊滑鼠顯示捷徑功能表:
  <script language="JavaScript">
   document.onmousedown = function popUp() {
    menu = document.all.itemopen
    if (event.button == 2) {
    newX = window.event.x + document.body.scrollLeft
    newY = window.event.y + document.body.scrollTop
    menu.style.display = ""
    menu.style.pixelLeft = newX
    menu.style.pixelTop = newY
    }
    else if (event.button == 1)
    {
     menu.style.display = "none"
    }
   }
  </script>

屏蔽IE預設的WinForm捷徑功能表:
  <script language="JavaScript">
   var message="";
   function clickIE()
   {
    if (document.all)
    {
     (message);
     return false;
    }
   }
   function clickNS(e)
   {
    if (document.layers||(document.getElementById&&!document.all))
    {
     if (e.which==2)
     {
      newX = window.event.x + document.body.scrollLeft
      newY = window.event.y + document.body.scrollTop
      menu = document.all.itemopen
      if ( menu.style.display == "")
      {
       menu.style.display = "none"
      }
      else
      {
       menu.style.display = ""
      }
      menu.style.pixelLeft = newX
      menu.style.pixelTop = newY
     }
     if (e.which==3)
     {
      (message);
      return false;
     }
    }
   }
   if (document.layers)
   {
    document.captureEvents(Event.MOUSEDOWN);
    document.onmousedown=clickNS;
   }
   else
   {
    document.onmouseup=clickNS;document.oncontextmenu=clickIE;
   }
   document.oncontextmenu=new Function("return false")
  </script>



相關文章

Cloud Intelligence Leading the Digital Future

Alibaba Cloud ACtivate Online Conference, Nov. 20th & 21st, 2019 (UTC+08)

Register Now >

Starter Package

SSD Cloud server and data transfer for only $2.50 a month

Get Started >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

聯繫我們

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

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