zoukankan      html  css  js  c++  java
  • 模拟鼠标双击事件方法

      

    doubleClick: function (o, fn) {
    o.count = 0;
    o.startTime = 0;
    o.delay;
    o.onmousedown = function () {
    if (this.count == 0) {
    this.startTime = new Date().getTime();
    var that = this;
    this.delay = setTimeout(function () {
    that.count = 0;
    that.startTime = 0;
    }, 2000);
    }
    this.count++;
    }
    o.onmouseup = function () {
    this.count++;
    if (this.count >= 3) {
    var shicha = new Date().getTime() - this.startTime;
    this.count = 0;
    this.startTime = 0;
    if (shicha < 600) {
    clearTimeout(this.delay);
    fn.call(this, this);
    return;
    }
    }
    }
    }

    chrome IE9+ ff 的双击事件分解为 mousedown mouseup mousedown mouseup,IE8 分解为mousedown mouseup mouseup。IE6 7没测

  • 相关阅读:
    NOI Online 2020「Prelude」
    CF704E Iron Man
    luogu P4619 [SDOI2018]旧试题
    luogu P4207 [NOI2005]月下柠檬树
    JOI2020
    luogu P3263 [JLOI2015]有意义的字符串
    p1864
    p1824
    p1836
    p1862
  • 原文地址:https://www.cnblogs.com/strangerqt/p/3565002.html
Copyright © 2011-2022 走看看