Monday, May 20, 2024
20
rated 0 times [  24] [ 4]  / answers: 1 / hits: 7383  / 10 Years ago, tue, may 27, 2014, 12:00:00

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;


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.


More From » event-handling

 Answers
4

You can try with following:



$(document).mousedown(function(e){
if(e.which === 2 ){
alert(middle click);
return false; // Or e.preventDefault()
}
});


Demo


[#45011] Monday, May 26, 2014, 10 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
dominiqued

Total Points: 189
Total Questions: 122
Total Answers: 103

Location: Ghana
Member since Sun, Mar 27, 2022
2 Years ago
;