Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mouseup, mouse down not working in android webview

Following jquery is not working in my android webview. When long press on a span for more than 10 seconds it needs to be redirected to a specific url, this is working on site but not working on 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!');
    }
  });
});
like image 975
Dev Avatar asked Feb 17 '26 21:02

Dev


1 Answers

Are you using a touchscreen? If so you may need to use 'touchstart' and 'touchend'

like image 158
AnthW Avatar answered Feb 20 '26 07:02

AnthW



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!