0

I have a tab-viewer written in html/css/javascript which I would like to change a bit, right now when I switch each tab all it does is switch the content. What I would like to do is open each tab up in a new window and id like each tab to be in separate files.

Is there any easy way of doing this?

user1535882
  • 119
  • 1
  • 3
  • 12
  • 1
    Are you sure you should be using tabs? That behavior doesn't sound very tabular. – yellottyellott Jul 31 '12 at 21:38
  • http://stackoverflow.com/questions/5141910/javascript-location-href-to-open-in-new-window-tab Link to previous question which should help. – Lemex Jul 31 '12 at 21:39
  • 1
    Can you explain what you mean by "tab"? It doesn't sound like you're talking about tabbed browsing. – Dai Jul 31 '12 at 21:39
  • well the content is still displayed as tabs, for simplicity id like to store the content in separate files, otherwise it gets rather extensive in each page. – user1535882 Jul 31 '12 at 21:41

2 Answers2

1

Put a link on the tabs with target="_blank"

<a href="tab1.html" target="_blank">Tab1</a>

Edit: The target attribute might be deprecated (or not: see @Tim Medora's comment) but is supported in all major browsers (http://www.w3schools.com/tags/att_a_target.asp) and is as close as you can get imo. From w3schools.com: _blank: Opens the linked document in a new window or tab

Horen
  • 11,184
  • 11
  • 71
  • 113
  • The `target` attribute is deprecated (even in HTML4), and most desktop browsers interpret the attribute to open a new window, not a new tab. – Dai Jul 31 '12 at 21:37
  • `target="_blank"` is deprecated, and some browsers have never honored that feature. – kevin628 Jul 31 '12 at 21:37
  • 1
    is there any replacement for target? – user1535882 Jul 31 '12 at 21:38
  • 2
    It's not deprecated: http://dev.w3.org/html5/markup/a.html#a.attrs.target. However, this is probably not the right solution for the question. – Tim M. Jul 31 '12 at 21:41
0

for simplicity id like to store the content in separate files, otherwise it gets rather extensive in each page

How about jQuery UI tabs + AJAX?

Docs: http://jqueryui.com/demos/tabs/#ajax
Demo: http://jqueryui.com/demos/tabs/ajax.html

Or, if you already have your own tab control, you could detect the tab change with a bit of JS and load the content dynamically with AJAX.

If you really want new windows (unclear from the question), then the use of tabs is misleading. At that point it should just be a menu. I would be confused/frustrated if tabs all opened in new windows.

Tim M.
  • 53,671
  • 14
  • 120
  • 163