禁用鼠标中键 [英] Disable middle mouse click
本文介绍了禁用鼠标中键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在一个问题上,我需要您的帮助,即如何禁用鼠标中键单击任何链接以在IE 7,8,9中打开新选项卡. 我已经尝试过很多类似
I need your help in one question that how to disable the middle mouse click on any link to open a new tab in IE 7,8,9. I have tried many thing like
return false;
e.cancelBubble = true;e.returnValue = false;
但是无法停止IE的功能以打开新建"标签.但是,如果我将警告消息e
But not able to stop that feature of IE to open New tab.But if i am putting alert message e
if (event.button == 4)
{
alert("shashank");
}
我可以停止打开新标签.但是我不想使用警报消息.
I am able to stop to open new tab .But I don't want to use alert message.
推荐答案
您可以尝试以下操作:
$(document).mousedown(function(e){
if(e.which === 2 ){
alert("middle click");
return false; // Or e.preventDefault()
}
});
这篇关于禁用鼠标中键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文