zoukankan      html  css  js  c++  java
  • 自定义上下文菜单,contextmenu事件

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Title</title>
        <style>
            #myDiv {
                cursor: context-menu;
            }
            #programMenu {
                padding: 0;
                width: 155px;
                position: absolute;
                visibility: hidden;
                background: #fff;
                color: #006696;
                font-size: 12px;
                border: 1px solid #cccccc;
                border-radius: 5px;
            }
            #programMenu li {
                list-style: none;
                list-style-position: outside;
                height: 25px;
                line-height: 25px;
                cursor: pointer;
                padding-left: 20px;
            }
            #programMenu li:not([class="disabled"]):focus,
            #programMenu li:not([class="disabled"]):hover,
            #programMenu li:not([class="disabled"]):active {
                background: #3f9afa;
                color: #f7fffc;
            }
            #programMenu li.disabled {
                color: #b7b7b7;
            }
        </style>
    </head>
    <body>
    <div id="myDiv">dYou’ve been added to the denstiny-code organization!
        Here are some quick tips for a first-time organization member.
        Use the switch context button in the upper left corner of this page to switch between your personal context (dxdleikai) and organizations you are a member of.
        After you switch contexts you’ll see an organization-focused dashboard that lists out organization repositories and activities. </div>
    <ul id="programMenu">
        <li>复制</li>
        <li>粘贴</li>
        <li class="disabled">删除</li>
    </ul>
    
    <script>
        var div = document.getElementById('myDiv');
        div.addEventListener('contextmenu', function (e) {
            e.preventDefault();
            var menu = document.getElementById('programMenu');
            menu.style.left = e.clientX + 'px';
            menu.style.top = e.clientY + 'px';
            menu.style.visibility = 'visible';
        }, false);
        document.addEventListener('click', function (e) {
    if (e.which === 1) { // 兼容firefox
                document.getElementById('programMenu').style.visibility = 'hidden';
            }
            
        }, false);
    </script>
    </body>
    </html>
  • 相关阅读:
    codesmith 连接mysql
    数据库 价格字段 设置 decimal(8,2),价格为100W,只显示999999.99
    AOP和IOC
    Android Studio 每次运行都会再下载一遍,修改
    gradle 的jar下载到哪里了
    遇到的坑
    Error:Failed to resolve: :Base:
    re-download dependencies and 无法下载jar 的解决
    DI是实现面向切面和面向抽象的前提
    基础才是重中之重~ConcurrentDictionary让你的多线程代码更优美
  • 原文地址:https://www.cnblogs.com/bagexiaowenti/p/9527366.html
Copyright © 2011-2022 走看看