欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

javascript鼠標(biāo)右鍵菜單自定義效果

 更新時(shí)間:2020年12月08日 15:36:06   作者:caichao  
設(shè)計(jì)專(zhuān)屬于自己的右鍵菜單,添加自己需要的快捷方式,本文就為大家分享自定義javascript鼠標(biāo)右鍵菜單的實(shí)現(xiàn)方法,感興趣的小伙伴們可以參考一下

本文實(shí)例講解了javascript鼠標(biāo)右鍵菜單的實(shí)現(xiàn)方法,分享給大家供大家參考,具體內(nèi)容如下

效果圖:

具體代碼:

<html>
 <head>
  <meta charset="gb2312" />
  <title></title>
  <style>
   #menu{
    border:solid 1px gray;
    width:100px;
    display:none;
    position:absolute;
    background-color:ghostwhite;
    margin: 0;
    padding: 0;
    list-style-type: none;
   }
   #menu>li{
    border-bottom: dashed 1px gray;
   }
  </style>
  <script type="text/javascript">
  window.onload=function(){
   var oUl=document.getElementById('menu');
    document.oncontextmenu=function(ev){
     var oEvent=ev||event;
     //一定要加px,要不然chrom不認(rèn)
     oUl.style.top=oEvent.clientY+'px';
     oUl.style.left=oEvent.clientX+'px';
     oUl.style.display='block';
     return false;
    }
    document.onclick=function(){
     oUl.style.display='none';
    }
  };
  </script>
 </head>
 <body>
<ul id="menu">
 <li><a href="http://www.dbjr.com.cn/" target="_blank">腳本之家</a></li>
 <li><a href="http://www.dbjr.com.cn/" target="_blank">腳本之家</a></li>
 <li><a href="http://www.dbjr.com.cn/" target="_blank">腳本之家</a></li>
 <li><a href="http://www.dbjr.com.cn/" target="_blank">腳本之家</a></li>
</ul>
 </body>
</html>

希望本文所述對(duì)大家學(xué)習(xí)javascript程序設(shè)計(jì)有所幫助。

相關(guān)文章

最新評(píng)論