I know I can use capture the Right Click event by using jQuery's "contextmenu" but my question is, how can I capture the event after the context menu appears i.e. When the user clicks on "Open Link in New Tab" action.
Any help?
Thanks.
I know I can use capture the Right Click event by using jQuery's "contextmenu" but my question is, how can I capture the event after the context menu appears i.e. When the user clicks on "Open Link in New Tab" action.
Any help?
Thanks.
No, it is not possible to directly capture the "Open in New Tab" event from the browser's context menu using JavaScript. This is due to security and privacy reasons, as browsers do not expose such low-level interactions to web pages.
I found this solution
<script type='text/javascript'>
jQuery(function($){
$('a').mousedown(function(event) {
switch (event.which) {
case 1:
//alert('Left mouse button pressed');
$(this).attr('target','_self');
break;
case 2:
//alert('Middle mouse button pressed');
$(this).attr('target','_blank');
break;
case 3:
//alert('Right mouse button pressed');
$(this).attr('target','_blank');
break;
default:
//alert('You have a strange mouse');
$(this).attr('target','_self"');
}
});
});
© 2022 - 2025 — McMap. All rights reserved.