I'm trying to "force" Safari or IE7 to open a new page using a new tab.
Programmatically I mean something like:
window.open('page.html','newtaborsomething');
I'm trying to "force" Safari or IE7 to open a new page using a new tab.
Programmatically I mean something like:
window.open('page.html','newtaborsomething');
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 happen 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 Firefox 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/
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.
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.
Have you already tried like
var open_link = window.open('','_blank');
open_link.location="somepage.html";
I found out in Chrome,
window.open('page.html','_newtab')
will only work once.
You can use:
window.open(ct.getNewHref(),'_newtab' + Math.floor(Math.random()*999999));
To open multiple new tabs.