[转]手机浏览器下IScroll中click事件无效的问题
产品的h5页面几乎都使用了iscroll插件,如果a标签在iscroll里,在部分手机浏览器中会出现无法点击的情况,不管是绑定click事件还是使用a标签的href属性。href属性偶尔还会能点击,click事件完全不能。
如果用button或input代替a,都能响应click事件。
如果用微信内置浏览器,都能响应click事件(nubia除外)。QQ浏览器也能响应。
也就是出现此问题跟手机本地浏览器,iscroll,a标签都有关系。
iScroll uses various techniques to scroll based on device/browser capability. Normally you don't need to configure the engine, iScroll is smart enough to pick the best for you.
别高兴的太早
Nonetheless it is important to understand which mechanisms iScroll works on and how to configure them.
options太多,直接看重点,click和tap
To override the native scrolling iScroll has to inhibit some default browser behaviors, such as mouse clicks. If you want your application to respond to the click event you have to explicitly set this option to true. Please note that it is suggested to use the custom tap event instead (see below).
重点就是这儿了,iscroll阻止了浏览器默认的行为,比如click。把click设置为true就ok了。不要问我为什么阻止了默认click之后,有的手机浏览器可以,有的不可以,这个我也不知道。- -。
如果只设置click为true,会出现部分a还是无法点击,再加上taps:true;
Set this to true to let iScroll emit a custom tap event when the scroll area is clicked/tapped but not scrolled.
如果您认为本文对得起您所阅读他所花的时间,欢迎点击右下角↘ 推荐。您的支持是我继续写作最大的动力,谢谢
作者:沧海月明
出处:http://www.cnblogs.com/xxcanghai/
本文地址:http://www.cnblogs.com/xxcanghai/
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。

浙公网安备 33010602011771号