jQuery:在新选项卡/窗口中打开链接时,不会调用点击处理程序 [英] jQuery: click handler is not invoked when link is opened in new tab/window

查看:115
本文介绍了jQuery:在新选项卡/窗口中打开链接时,不会调用点击处理程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我已经注意到当用户点击链接时,例如中间按钮或shift / ctrl +左键,我已经看到了跟踪mousedown事件的解决方案,但我想要的是跟踪一个链接的确切事件。



有什么建议吗?感谢

解决方案

mousedown / code>确实是唯一可以得到中间按钮交互的通知,所以检测一个down-then-up事件,而没有插入 mouseout 事件或多或少最好你能做到。这不是很好。



我不会打扰,因为即使你陷入这一个可能性,还有很多其他的互动,你不能拾起。除了中间点击(它可能不是在所有浏览器/配置中的在新选项卡中打开;例如在IE6中,用户打开滚动模式),用户可以右键单击和在新的打开窗口,或将链接拖动到地址栏或新标签,或各种其他浏览器特定的操作来执行导航。


I have noticed when user clicks on a link with, say middle button, or shift/ctrl+left button, click handler attached to hyperlink is not called.

I have seen solutions to track mousedown event, but what I'd like is to track exact event of following a link.

Are there any suggestions? Thanks

解决方案

mousedown/mouseup is indeed the only way you can get notified of middle button interaction, so detecting a down-then-up event without intervening mouseout event is more or less the best you can do. It's not very good.

I wouldn't bother, since even if you trapped this one eventuality, there are many other interactions you can't pick up. As well as middle-click (which might not be ‘Open in new tab’ in all browser/configurations; for example in IE6 that'll be the user turning on scrolling mode), the user might right-click and ‘Open in new window’, or drag the link to the address bar or new tab, or various other browser-specific actions to perform a navigation.

这篇关于jQuery:在新选项卡/窗口中打开链接时,不会调用点击处理程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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