原文:http://hicc.me/post/webkit-user-select-none-disabling-text-field.htmlcss
最近在webview中寫頁面的時候發現個別Android機型(Google Nexus,Android 4.2.2)輸入框沒法輸入(可是鍵盤能夠彈起,因此不是網上所說webView.requestFocus(View.FOCUS_DOWN);
的問題),通過試錯發現是-webkit-user-select:none;
所致使的緣由。html
後來網上再搜,果真有一樣的問題,Phonegap styles -webkit-user-select: none; disabling text fieldnode
固然若是你確實須要這個-webkit-user-select這個屬性,也能夠這樣寫css代碼(來源於上述的stackoverflow上的回答。):git
*:not(input,textarea) { -webkit-touch-callout: none; -webkit-user-select: none; }
在此還想作的引伸是,若是是web應用使用了iscroll這個插件,在某些機型上在iscroll4的滾動容器範圍內,點擊input框、select等表單元素時沒有響應,光標不定位,鍵盤不彈出,緣由在於iscroll一直監聽用戶的touch操做,以便靈敏的作出對應效果,因此它把其他的默認事件屏蔽了,解決的方法是,在iscroll4源碼裏面找到這一行:github
onBeforeScrollStart: function (e) { e.preventDefault(); } //改成 onBeforeScrollStart: function (e) { var nodeType = e.explicitOriginalTarget ? e.explicitOriginalTarget.nodeName.toLowerCase():(e.target ? e.target.nodeName.toLowerCase():」);if(nodeType !=’select’&& nodeType !=’option’&& nodeType !=’input’&& nodeType!=’textarea’) e.preventDefault(); }
上述代碼來自:http://www.gafish.net/archives/1141,
還有插件官方的解決方案:https://github.com/cubiq/iscroll/commit/feb0088a996a28ebd0a7a37ee7b9e31a50a4a58eweb