编辑右键菜单--换成自己需要的菜单

<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title></title>
    <style>
        *{margin:0;padding:0;list-style:none;}
        #div1{position:absolute;width:100px; top:0; left:0; background:red;display: none;}
    </style>
   
</head>
<body>
<div id="div1">
    <ul>
        <li><a href="#">11111111</a></li>
        <li>11111111</li>
        <li>11111111</li>
        <li>11111111</li>
        <li>11111111</li>
        <li>11111111</li>
        <li>11111111</li>
    </ul>

</div>
</body>
</html>
html
 <script>
        document.oncontextmenu=function(e){
            var even=e||event;
            var oDiv=document.getElementById("div1");
            oDiv.style.display="block";
            oDiv.style.left= e.clientX+"px";
            oDiv.style.top= e.clientY+"px";
            document.onclick=function(){
                var oDiv=document.getElementById("div1");
                oDiv.style.display="none";
            };
            return false;
        };

    </script>
js

 

posted @ 2016-08-08 16:16  dongxiaolei  阅读(222)  评论(0编辑  收藏  举报