iPad/iPhone 悬停问题导致用户双击链接 [英] iPad/iPhone hover problem causes the user to double click a link

查看:23
本文介绍了iPad/iPhone 悬停问题导致用户双击链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我以前建立了一些网站,它们使用 jquery 鼠标事件...我刚买了一个 ipad,我注意到所有鼠标悬停事件都被转换为点击...所以例如我必须点击两次而不是一个..(第一次悬停,而不是实际点击)

I have some websites I built times ago, that use jquery mouse events...I just got an ipad and i noticed that all the mouse over events are translated in clicks...so for instance i have to do two clicks instead of one..(the first hover, than the actual click)

是否有解决方法可以解决这个问题?也许我应该使用 jquery 命令而不是鼠标悬停/退出等.谢谢!

is there a workaround ready to solve this? maybe a jquery command i shoudl have used instead of mouseover/out etc.. thanks!

推荐答案

尚未对此进行全面测试,但由于 iOS 会触发触摸事件,因此假设您处于 jQuery 设置中,这可能会起作用.

Haven't tested this fully but since iOS fires touch events, this could work, assuming you are in a jQuery setting.

$('a').on('click touchend', function(e) {
    var el = $(this);
    var link = el.attr('href');
    window.location = link;
});

这个想法是移动 WebKit 在点击结束时触发一个 touchend 事件,所以我们会监听它,然后在 touchend 事件发生后立即重定向浏览器被链接触发.

The idea is that Mobile WebKit fires a touchend event at the end of a tap so we listen for that and then redirect the browser as soon as a touchend event has been fired on a link.

这篇关于iPad/iPhone 悬停问题导致用户双击链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆