0

I've got something like this.

Question: How to disable opening Home and Profile tabs in new window?

VB_
  • 45,112
  • 42
  • 145
  • 293
  • Did you try removing the `data-toggle` arguments? – bosnjak Mar 24 '14 at 14:31
  • @Lawrence yes, no result. – VB_ Mar 24 '14 at 14:32
  • Then it is most likely defined in the CSS for `nav nav-tabs`. Please attach the CSS *relevant* contents. – bosnjak Mar 24 '14 at 14:41
  • @Lawrence look at additional section of my question. I've posted the whole css. – VB_ Mar 24 '14 at 14:48
  • Hm, i can't reproduce the issue in [JSFiddle](http://jsfiddle.net/UNuv4/). There could be some JS code on the page that is doing this? – bosnjak Mar 24 '14 at 14:52
  • @Lawrence reproduce what? I want change standard bootstrap behavior. – VB_ Mar 24 '14 at 14:54
  • could you please, explain a bit more about what you are trying to do? I couldn't actually capture it even after I've gone through entire discussion. – code-jaff Mar 24 '14 at 15:50
  • @code-jaff I use twitter-bootstrap. That means I can set special classes to my html-elements and they'll be displayed as popups, tabs, dialogs etc. If I want tabs inside dialog I should use `li` element with `a` inside. Now I want to prevent user open those `a` reference in new tab. – VB_ Mar 25 '14 at 09:59
  • @VolodymyrBakhmatiuk Ok, what actually confuses was, you mean by tab is browser tab or bootstrap tab? – code-jaff Mar 25 '14 at 10:43
  • @code-jaff I mean both ). Bootstrap displays `a` references as dialog tabs; I want to disable opening those bootstrap-tabs in new BROWSER tab – VB_ Mar 25 '14 at 10:46
  • @VolodymyrBakhmatiuk As far as I know you cannot prevent that. This sounds like how to prevent a browser from going to a particular URL. – code-jaff Mar 25 '14 at 11:12
  • @code-jaff actually the question is "how to intercept `go to new tab` event?". Is that impossible? – VB_ Mar 25 '14 at 11:26
  • @code-jaff look at upgraded question with demo please – VB_ Mar 25 '14 at 12:22
  • @Lawrence look at upgraded question with demo please – VB_ Mar 25 '14 at 12:33

3 Answers3

3

The solution is very simple: add oncontextmenu="return false;" to the ul element.

<ul class="nav nav-tabs" oncontextmenu="return false;">
  <li class="active"><a href="#home" data-toggle="tab">Home Tab</a></li>
  <li><a href="#profile" data-toggle="tab">Profile Tab</a></li>
</ul>
VB_
  • 45,112
  • 42
  • 145
  • 293
0

You can disable the links from doing anything:

$('#view-modal-nav a').click(function(event){
  event.preventDefault();
  //handle your code here
});
Kamran224
  • 1,584
  • 7
  • 20
  • 33
  • I want they work. The problem is that I have SPA with single entry point. I mean to open some url, user must go through home-page. So I should disable opening links in new tab/window. – VB_ Mar 24 '14 at 14:56
  • @VolodymyrBakhmatiuk You can handle that in the javascript function. I'm not sure if there is any other way to disable opening links in a new tab/window. – Kamran224 Mar 24 '14 at 14:58
  • how? I know how to intercept event. How can I distinguish whether user is gonna open link in the same tab or new one? – VB_ Mar 24 '14 at 15:00
  • @VolodymyrBakhmatiuk You can check if the user is going to middle mouse with the event object. If you want to disable open in new link on right click, refer to http://stackoverflow.com/questions/17169198/how-to-disable-or-hide-the-open-in-new-tab-option-for-hyperlinks . You might have to do both – Kamran224 Mar 24 '14 at 15:05
  • look at upgraded question with demo please – VB_ Mar 25 '14 at 12:39
0

Try using this

$('#view-modal-nav a').click(function (e) {   
       e.preventDefault(); //Prevents Opening of Links
       $(this).tab('show'); //Shows the Corresponding tab
});
raghav
  • 285
  • 2
  • 12