zoukankan      html  css  js  c++  java
  • 双击文本没有被选中

    IE浏览器使用document.selection当前用户激活对象选择区域,通过后获取当前用户的操作区document.selection.empty()功能来实现双击选定的文本不起作用。不IE浏览器使用window.getSelection对象选择当前用户激活区域。在获取当前用户操作区域后通过removeAllRanges()函数实现双击不选中文本功能

    <script type="text/javascript">
    $(document).ready(function(){
        var clearSeletion=function(){
            if(document.selection&&document.selection.empty){
                document.selection.empty();
            }else if (window.getSelection) {
                var sel=window.getSelection();
                sel.removeAllRanges();
            }
        };
        $("#element").bind("dblclick",function(event){
            clearSeletion();
        });
    });
    </script>
    </head>
    <body>
        <p>鼠标双击測试区域(灰色)</p>
        <div id="element" style="background-color: #E8E8E8;">dbclick selection text</div>
    </body>

    版权声明:本文博主原创文章,博客,未经同意不得转载。

  • 相关阅读:
    zabbix入门知识
    flask_login
    flask_数据库
    flask_web表单
    flask_模板
    flask_hello world
    1024 Hello World
    使用bat批处理文件备份postgresql数据库
    使用bat批处理文件备份mysql数据库
    在windows7下创建ftp服务站点
  • 原文地址:https://www.cnblogs.com/yxwkf/p/4777691.html
Copyright © 2011-2022 走看看