mouseup、mouse down 在 android webview 中不起作用

2024-01-24

以下 jquery 在我的 android webview 中不起作用。当长按跨度超过 10 秒时,需要重定向到特定的 url,这在网站上有效,但在 android webview 上不起作用。

$(function() {
  var longpress = 10000;
  var start;

  jQuery("#restart").on('mousedown', function(e) {
    start = new Date().getTime();
  });

  jQuery("#restart").on('mouseleave', function(e) {
    start = 0;
  });

  jQuery("#restart").on('mouseup', function(e) {
    if (new Date().getTime() >= (start + longpress)) {
      alert('long press!');
      $("#restart >a").attr("href", "http://siteurl/?key=gesture")
    } else {
      alert('short press!');
    }
  });
});

您使用触摸屏吗?如果是这样,您可能需要使用“touchstart”和“touchend”

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

mouseup、mouse down 在 android webview 中不起作用 的相关文章

随机推荐