Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Programmatically open new pages on Tabs

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'); 
like image 594
Ricardo Vega Avatar asked Jan 09 '09 09:01

Ricardo Vega


People also ask

How do I make a link open in a new tab instead of a new window?

To open a link in a new tab, click the link by pressing down your middle mouse button, or right-click the link and select Open link in New Tab. If your mouse has a wheel, it can be used as a button if you press down on the wheel. These methods work in all of the major Internet browsers available for Microsoft Windows.

How do I get a new tab to open automatically in HTML?

The short answer is: just add a target="_blank" attribute to your links (anchor tags). Now when your visitors click that link, it will open in a new window or tab (depending on which web browser they are using and how they configured that browser).


2 Answers

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/

like image 74
Eineki Avatar answered Sep 18 '22 22:09

Eineki


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.

like image 35
thenonhacker Avatar answered Sep 18 '22 22:09

thenonhacker