欢迎访问 生活随笔!

生活随笔

当前位置: 首页 > 编程资源 > 编程问答 >内容正文

编程问答

页面右键下拉表

发布时间:2025/5/22 编程问答 32 豆豆
生活随笔 收集整理的这篇文章主要介绍了 页面右键下拉表 小编觉得挺不错的,现在分享给大家,帮大家做个参考.
程序代码
<script type="text/javascript" language="javascript" >
        document.οncοntextmenu=click;
        var appState = new applicationState();
        function applicationState() {
            this.contextMenu = null;
        }
        function click()
        {
            var str="";
                str="<div style='position: absolute;background-color:#48b4fc;'><table border='1'>";
                str+="<tr οnmοuseοver='fn_set(this);'><td>111<td><tr>";
                str+="<tr οnmοuseοver='fn_set(this);'><td>222<td><tr>";
                str+="<tr οnmοuseοver='fn_set(this);'><td>333<td><tr>";
                str+="<tr οnmοuseοver='fn_set(this);'><td>444<td><tr>";
                str+="</table></div>";
            if(appState.contextMenu != null) appState.contextMenu.removeNode(true)

            document.body.insertAdjacentHTML("beforeEnd", str)
            contextMenu = document.body.childNodes(document.body.childNodes.length-1)
            contextMenu.style.left = window.event.x
            contextMenu.style.top = window.event.y;
            appState.contextMenu = contextMenu
            window.event.cancelBubble = true;
            return false;
        }
        function fn_set(obj){
            obj.style.color="#24b400";
        }
        function clean() {
          var contextMenu
          if(appState.contextMenu != null) {
            contextMenu = appState.contextMenu.removeNode(true)
            contextMenu = null
          }
        }
        </script>
        <script event=onclick() for="document" type="text/javascript">clean();</script>//处理页面单击事件,关闭下拉表

转载于:https://www.cnblogs.com/Bany/archive/2007/02/25/1755511.html

《新程序员》:云原生和全面数字化实践50位技术专家共同创作,文字、视频、音频交互阅读

总结

以上是生活随笔为你收集整理的页面右键下拉表的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。