移动端页面中,长按可选中文本;但有时候为了更好地用户体验需禁用此功能。
方法一:
* {
-webkit-user-select:none;
-moz-user-select:none;
-ms-user-select:none;
user-select:none;
}
注:此方法会带来以下问题--
问题一:这样会让iOS的input框无法聚焦
解决方案:
input{-webkit-user-select:auto;}问题二:如果需要长按发送语音,禁用长按之后,无法长按发送语音
解决方案:
<div class="voice-speak" ontouchstart="return false;" style="display: none" id="startRecord"><span>按住说话</span></div>
方法二:
div { pointer-events: none;}
方法三:
window.ontouchstart = function(e) { e.preventDefault(); };
本文介绍如何在移动端页面上禁用长按选中文本的功能,并提供了三种方法及相应的解决方案来避免影响输入框聚焦和长按语音发送等问题。

818

被折叠的 条评论
为什么被折叠?



