iPad / iPhone悬停问题会导致用户双击链接 [英] iPad/iPhone hover problem causes the user to double click a link
问题描述
我有一些我之前建立的网站,使用jquery鼠标事件......我刚刚买了一个ipad,我注意到所有鼠标悬停的事件都是在点击中翻译的......所以我必须做两次点击而不是一个..(第一个悬停,比实际点击)
是否有解决方法可以解决这个问题?也许一个jquery命令我shoudl使用,而不是鼠标悬停/出等。
谢谢!
没有测试这完全,但由于iOS触发事件触发,这可以工作,假设你在jQuery设置。 ').on('click touchend',function(e){
var el = $(this);
var link = el.attr('href');
window.location = link;
});
这个想法是Mobile WebKit触发 touchend
事件,所以我们监听它,然后在链接上触发 touchend
事件后立即重定向浏览器。
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)
is there a workaround ready to solve this? maybe a jquery command i shoudl have used instead of mouseover/out etc.. thanks!
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;
});
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屋!