• javascript双击和单击事件共存


    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="UTF-8">
    <title></title>
    <style>
            .quick{
     105px;
    height: 36px;
    background-image: url("ic_cloud_upload_white_24dp.png");
    background-repeat: no-repeat;
    background-color: black;
    cursor:pointer;
            }
            .quick img {
    visibility: visible;
    position: absolute;
            }
    
            .quick span {
    font-size: 14px;
    /*padding-top: 12px;*/
    float: right;
    color: white;
    line-height: 40px;
            }
            //这里为双击文字时,背景色不让其高亮
    body{-moz-user-select:none;}//火狐
    /*<body onselectstart="return false">*/其他浏览器
    </style>
    <script type="text/javascript">
    var clickTimer = null;
    function _click(){
    if(clickTimer) {
    window.clearTimeout(clickTimer);
    clickTimer = null;
                }
    
    clickTimer = window.setTimeout(function(){
    // your click process code here
    alert("你单击了我");
                }, 300);
            }
    function _dblclick(){
    if(clickTimer) {
    window.clearTimeout(clickTimer);
    clickTimer = null;
                }
    alert("你双击了我");
            }
    
    </script>
    </head>
    <body >
    <div onselectstart="return false" onclick="_click();" ondblclick="_dblclick();" class="quick"><img src="uploading.gif"><span>快捷上传</span></div>
    </body>
    </html>
     
    业勤于精荒于嬉 http://www.cnblogs.com/maxlei/
  • 相关阅读:
    UVa 1331 最大面积最小的三角剖分
    UVa 1626 括号序列(矩阵连乘)
    POJ 3295 Tautology(构造法)
    POJ 2586 Y2K Accounting Bug(贪心)
    POJ 2109 Power of Cryptography
    abcd
    好数
    Gift
    密码游戏
    约瑟夫游戏
  • 原文地址:https://www.cnblogs.com/maxlei/p/5954032.html
Copyright © 2020-2023  润新知