禁用鼠标中键
问题描述:
在一个问题上,我需要您的帮助,即如何禁用鼠标中键单击任何链接以在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()
}
});