Reputation: 223
I am using Bootstrap 3 and I am looking for a way to prevent my modal dialog windows to open for Open in a new tab / window. The modal window has to be opened (on top of current window) only with a direct click and not be displayed when the user right clicks on "Open in new tab / Window". Any help would be appreciated, thanks
Upvotes: 0
Views: 1566
Reputation: 604
Hmm, this will be difficult cross-browser/device wise - open link in new window is same request to browser (no JS way of knowing the difference).
Maybe it could be done with localstorage/cookies and active browser tab detection with some capture right click method (all logically connected in a function) but I think it could be very prone to (cross-browser/device) inconsistencies...
So - personally I would try to write a method: - checking for right click (don't forget touch devices) - or as shiva proposed (oncontextmenu), saving "state" in localstorage/cookie, - checking for that state at page init and disabling modal(s) appropriately.
Test on multiple devices...
Upvotes: 0
Reputation: 223
On the element you can use oncontextmenu
<ul class="nav nav-tabs" oncontextmenu="return false;">
<li><a href="#tab1" data-toggle="tab">tab1</a></li>
<li><a href="#ab2" data-toggle="tab">tab2</a></li>
</ul>
Upvotes: 2