iscroll4 input textarea不能获得焦点问题

Posted 一线蓝光

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了iscroll4 input textarea不能获得焦点问题相关的知识,希望对你有一定的参考价值。

  最近在做移动端项目的时候,使用iscroll4实现页面滚动效果,之后发现页面中的input,textarea等不能得到焦点,输入内容。

  问题原因是: 使用iscroll之后,输入框无法聚焦,页面文字等无法复制, iscroll主要一直监听用户的touch操作和鼠标事件,所以把其余事件都屏蔽了,禁止了浏览器的默认行为。

  解决办法:把源代码中的onBeforeScrollStart 函数中内容替换成

     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.cnblogs.com/duanhuajian/archive/2012/11/09/2763159.html

以上是关于iscroll4 input textarea不能获得焦点问题的主要内容,如果未能解决你的问题,请参考以下文章

使用iscroll4可能会遇到的问题(转:记录)

使用iscroll4可能会遇到的问题(转:记录)

js控制ios端的input/textarea元素失去焦点时隐藏键盘

取消chrome浏览器下input和textarea的默认样式

取消chrome浏览器下input和textarea的默认样式

Textarea 可编辑,除了来自输入的值