mouseup, mouse down 在 android webview 中不起作用
mouseup, mouse down not working in android webview
关注 jquery 在我的 android 网络视图中不起作用。当长按 span 超过 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'
或者使用 touchstart
、touchleave
和 touchend
$(function() {
var longpress = 10000;
var start;
jQuery("#restart").on('mousedown touchstart', function(e) {
start = new Date().getTime();
});
jQuery("#restart").on('mouseleave touchleave', function(e) {
start = 0;
});
jQuery("#restart").on('mouseup touchend', function(e) {
if (new Date().getTime() >= (start + longpress)) {
alert('long press!');
$("#restart >a").attr("href", "http://siteurl/?key=gesture")
} else {
alert('short press!');
}
});
});
关注 jquery 在我的 android 网络视图中不起作用。当长按 span 超过 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'
或者使用 touchstart
、touchleave
和 touchend
$(function() {
var longpress = 10000;
var start;
jQuery("#restart").on('mousedown touchstart', function(e) {
start = new Date().getTime();
});
jQuery("#restart").on('mouseleave touchleave', function(e) {
start = 0;
});
jQuery("#restart").on('mouseup touchend', function(e) {
if (new Date().getTime() >= (start + longpress)) {
alert('long press!');
$("#restart >a").attr("href", "http://siteurl/?key=gesture")
} else {
alert('short press!');
}
});
});