javascript - 如何禁用 log press cordova android 的默认行为

标签 javascript android jquery css cordova

它是基于 Jqueryhtmlcss 的应用程序,使用 Cordova 构建 APK。

我有另一个功能是通过在屏幕上长按来执行的,它通过单击两个字符串的中间来工作,以避免出现默认对话框。大多数情况下,默认设备长按对话框弹出窗口出现在屏幕顶部。如何禁用下面屏幕截图中显示的顶部?尝试了一些 cssJavascript 技巧,但无济于事。

Check screenshot here

这是长按对话框的代码

$(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/

相关文章:

javascript - 更新用户生成的标记的搜索结果

javascript - 如何偏移 ol.style.Circle 或 ol.style.RegularShape?

android - 如何在源代码管理下处理 Android Gradle 文件?

android - 如何在 Android 中使用 Facebook Audience Network 解决错误 = 1001 "No Fill"

带有自定义 JSON 对象的 jQuery UI 自动完成

java - 如何将 Servlet 的请求转发到 JSP 页面的特定选项卡?

javascript - 如何使用 jquery 获取以下格式的当前日期

javascript - 如何阻止我的角色走出 div?

javascript - 使用 AJAX 将数据发布到 API

android - 在自定义警报对话框中显示 map