views:

6268

answers:

7

Hi, I'm trying to "force" Safari or IE7 to open a new page USING A NEW TAB!.

Sorry, It seems like an impossible task :( Programmatically I mean something like:

window.open('page.html','newtaborsomething');

Thanks!

+4  A: 

It's up to the user whether they want to use new tabs or new windows, it isn't the business of the developer to modify this behaviour. I do not think you can do it.

Pet peeve of mine - I hate it when sites force me to open in a new window / tab - I am quite capable of making that decision for myself. Particularly when they do it in javascript - that is really unhelpful.

Sam Meldrum
+1 to Sam - new pages opening in tabs or windows is a browser (and user) specific choice. In general I hate it when any site opens a new window.
Richard Ev
In addition to this: In the "strict" definition, there's no valid attribute "target" because of not annoying the user. Try it: http://validator.w3.org
furtelwart
I like opening batches of tabs at home, so I am the user in that case. Just a reminder that there are exceptions.
Mark Essel
A: 

I am not sure I get the point - are you developing an app, which works with IE and you want to open each new page on new tab? Or you just want to set up the IE to open new tab when clicked on a link? Or are you creating any site with more links and you want them to open separately? Pls make it clearlier.

Dungeo
+9  A: 

You can, in firefox it works, add the attribute target="_newtab" to the anchor to force the opening of a new tab.

<a href="some url" target="_newtab">content of the anchor</a>

In javascript you can use

window.open('page.html','_newtab');

Said that, I partially agree with Sam. You shouldn't force user to open new pages or new tab without showing them a hint on what is going to appen before they click on the link.

Let me know if it works on other browser too (I don't have a chance to try it on other browser than firedox at the moment).

Edit: added reference for ie7 Maybe this link can be useful
http://social.msdn.microsoft.com/forums/en-US/ieextensiondevelopment/thread/951b04e4-db0d-4789-ac51-82599dc60405/

Eineki
Thanks for this Firefox tip, now I have updated my TargetKiller addon to remove "_newtab" and "newtab". :P
thenonhacker
I really appreciate your answer, but I do know that Firefox will do it (some texts, not tested by me, remark that this is not always true, there's a 50-50 chance to get a new window or tab).I also think this shouldn't be an issue, but, you know clients :)
Ricardo Vega
This may not be the case on all builds/platforms, but Firefox 3.5 on Linux doesn't allow you to do this more than once... if you have multiple target="_newtab" links on your page, clicking on any of them will only populate a *single* new tab... that is, subsequent clicks will overwrite anything opened previously in that tab. Makes me think this is actually opening a tab *named* "_newtab", rather than being a browser-specific workaround.
Ryan Corradini
+2  A: 

You can't directly control this, because it's an option controlled by Internet Explorer users.

Opening pages using Window.open with a different window name will open in a new browser window like a popup, OR open in a new tab, if the user configured the browser to do so.

thenonhacker
Thanks, my client understand this now. Thanks for going to the point.
Ricardo Vega
A: 

I found out in Chrome,

window.open('page.html','_newtab')

will only work once.

If you run this script again on the same page, it'll only change the new tab's URL that you've created before but not opening another new tab.

Derek
A: 

I said,
In Google Chrome, when I run it 2 times, it'll still only open 1 new tab.
It changes the new tab's URL that created before instead.

Derek
A: 

a href=http://www.google.com target="_self">New Tab Example

Works in IE7 (note: I left off the opening "<" at the beginning of the code so you can view the text version of the code (add the "<" to work in your code).

Regards,

Glenn

Glenn Moore