它是基于 Jquery
、html
、css
的应用程序,使用 Cordova 构建 APK。
我有另一个功能是通过在屏幕上长按来执行的,它通过单击两个字符串的中间来工作,以避免出现默认对话框。大多数情况下,默认设备长按对话框弹出窗口出现在屏幕顶部。如何禁用下面屏幕截图中显示的顶部?尝试了一些 css
和 Javascript
技巧,但无济于事。
这是长按对话框的代码
$(document).on("mousedown touchstart","#table_discrepancy tr", function() {
var orderno = $(this).find("td:eq(0)").text();
var workorderno = $(this).find("td:eq(1)").text();
var timer = setTimeout(function() {
server('/get_customer_info/' + orderno, function(result){
var cus_name = result.name.replace(/^[\s]+/, '');
cus_name = cus_name.replace(/\w\S*/g, function(txt){return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();});
var phone_no = result.phoneno.replace(/^[\s]+/, '');
var email = result.email.replace(/^[\s]+/, '');
$('#customer_info_modal').modal('show');
$('#orderno_modal').html('Order# : ' + orderno);
$('#workorderno_modal').html('Work Order# : ' + workorderno);
$('#customer_name_modal').html('Name : ' + cus_name);
$('#customer_phoneno_modal').html('Phone#: ' + phone_no);
$('#customer_email_modal').html('Email: ' + email);
});
}, 1000);
$(this).on("mouseup touchstart", function() {
clearTimeout(timer);
});
})
最佳答案
通过在正文中添加类定义的 CSS
来阻止,它不允许从屏幕上选择任何内容
.noselect {
-webkit-touch-callout: none; /* iOS Safari */
-webkit-user-select: none; /* Safari */
-khtml-user-select: none; /* Konqueror HTML */
-moz-user-select: none; /* Firefox */
-ms-user-select: none; /* Internet Explorer/Edge */
user-select: none; /* Non-prefixed version, currently
supported by Chrome and Opera *
}
关于javascript - 如何禁用 log press cordova android 的默认行为,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45743983/