【问题标题】:How to disable the default behavior of log press cordova android如何禁用log press cordova android的默认行为
【发布时间】:2018-01-26 09:25:21
【问题描述】:

它是基于 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);
});
})

【问题讨论】:

  • 请添加您的代码
  • 你试过 mouseup , mousedown 吗?
  • 是的@AghoriTantrik
  • 代码添加@Observer
  • 尝试做“mousedown touchstart”和“mouseup touchstart”

标签: javascript android jquery css cordova


【解决方案1】:

通过在正文中添加带有类定义的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 *
     }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-04-17
    • 1970-01-01
    • 1970-01-01
    • 2013-12-19
    • 1970-01-01
    • 2017-09-19
    • 1970-01-01
    相关资源
    最近更新 更多