如何捕获“在新选项卡中打开” jquery.click 中的点击次数
我有一个 jquery 脚本,它将单击事件附加到每个链接,在单击链接时运行一个操作。 这一直很有效,但我刚刚收到了一些测试人员的反馈,这让我很沮丧。
用户右键单击该链接并在新选项卡中打开它。 当她这样做时,jquery 没有捕获点击。 坏用户。 我也用 cmd-click 重现了这个。
有没有办法捕获这些手势,或者这是一个固有的限制?
I have a jquery script that attaches a click event to every link, running an action when the link is clicked. This has been working great, but I just got some betatester feedback that's foiling me.
The user was right-clicking on the link and opening it in a new tab. When she did this, jquery didn't trap the click. BAD USER. I reproduced this with cmd-click as well.
Is there a way to trap these gestures, or this an inherent limitation?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
那么您想捕获每次点击吗? 事件是右边还是中间? mousedown 事件 不应该这样做吗?
当然,她可以右键单击一个链接,只是“复制链接位置”……
So you want to capture every click? Event the right or middle one? Shouldn't the mousedown event do just that?
Of course, she could right click a link just to "Copy Link Location"...
看看你是否可以以某种方式使用 jQuery 右键插件:
http://abeautifulsite.net/notebook/68
用法:
至于cmd-clickie位,我真的不确定。 如果它有帮助,这里是 jQuery 热键插件:
http://www.webappers.com/2008/07/31/bind-a-hot-key-combination-with-jquery-hotkeys/
See if you can somehow make use of jQuery rightclick plugin:
http://abeautifulsite.net/notebook/68
Usage:
As for the cmd-clickie bit, I'm really not sure. In case it's helpful, here's the jQuery hotkeys plugin:
http://www.webappers.com/2008/07/31/bind-a-hot-key-combination-with-jquery-hotkeys/
我在 firebug 中看到了 jquery.rightclick.js 代码。 mousedown 和 mouseup 事件有一些修饰符,例如:
altKey
ctrlKey
因此您可以使用这两个修饰符:
if(evt.altKey || evt.ctrKey)
jquery.rightclick.js 中的
I've seen jquery.rightclick.js code in firebug. There are modifiers with the mousedown and mouseup event like:
altKey
ctrlKey
so you can use these two modifiers:
if(evt.altKey || evt.ctrKey)
in jquery.rightclick.js