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

posted @ 2017-05-25 11:22  一线蓝光  阅读(691)  评论(0编辑  收藏  举报