HTML: how to force links to open in a new tab, not new window

HtmlCross BrowserTabs

Html Problem Overview


I use target="_blank" to open links in a new tab. But in IE it opens a new window which is completely logical because that is what _blank is supposed to do.

And i don't know how target="_blank" behaves in other browsers.

Is there something to force links to open in a new tab. If the browser supports tabs... else make a new window

Html Solutions


Solution 1 - Html

There is no way to do that as the author of the HTML that a browser renders. At least not yet that I know of. Its pretty much up to the browser and its settings / preferences that are set by users themselves.

Also, you shouldn't impose this upon any user. A browser is the user's property. If a user wants to open all links in tabs or in new windows, then let the user do exactly that.

It's good that we can't do certain things. target=_blank is still abused and popups have been done to death.

Solution 2 - Html

Since I fell into this old question and then found that it is now possible (maybe this css option wasn't available then), I just want to add an update on how it can be done:

<a href="[yourlink]" target="_blank" style="target-new: tab;">Google</a>

Here are the options for the target-new style:

target-new: window | tab | none 

Didn't test the none option, maybe it uses the default browser setting.

I confirmed this for Firefox and IE7-9.

Solution 3 - Html

No, there isn't.

Solution 4 - Html

I hope this will help you

window.open(url,'_newtab');

Solution 5 - Html

I didn't try this but I think it works in all browsers:

target="_parent"

Solution 6 - Html

The way the browser handles new windows vs new tab is set in the browser's options and can only be changed by the user.

Solution 7 - Html

onclick="window.open(this.href,'_blank');return false;"

Solution 8 - Html

a {
    target-name: new;
    target-new: tab;
}

The target-new property specifies whether new destination links should open in a new window or in a new tab of an existing window.

Note: The target-new property only works if the target-name property creates a new tab or a new window.

Solution 9 - Html

You can change the way Safari opens a new page in Safari > Preferences > Tabs > 'Open pages in tabs instead of windows' > 'Automatically'

Solution 10 - Html

You can set IE to open links in new tab, just go to the settings menu.

Solution 11 - Html

In Internet Explorer, click the Tools -> Internet Options. Click General tab -> Tabs -> Settings. Choose "When a pop-up is encountered"-> Always open pop up in new tab option. Click OK.

Solution 12 - Html

It is possible!

This appears to override browser settings. Hope it works for you.

<script type="text/javascript">
// Popup window code
function newPopup(url) {
    popupWindow = window.open(url,'popUpWindow1','height=600,width=600,left=10,top=10,resizable=yes,scrollbars=yes,toolbar=yes,menubar=no,location=no,directories=no,status=yes')
}
</script>

<body>
  <a href="JavaScript:newPopup('http://stimsonstopmotion.wordpress.com');">Try me</a>
</body>

Solution 13 - Html

Simply using "target=_blank" will respect the user/browser preference of whether to use a tab or a new window, which in most cases is "doing the right thing".

If you specify the dimensions of the new window, some browsers will use this as an indicator that a certain size is needed, in which case a new window will always be used. Stack overflow code example Stack Overflow

Solution 14 - Html

Try with javascript function like this

Html:

<a href="javascript:void(0)" onclick="open_win()">Target</a>

Javascript:

<script>
function open_win() 
{
window.open("https://www.google.co.in/");
}
</script>

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionMoonView Question on Stackoverflow
Solution 1 - HtmlMoin ZamanView Answer on Stackoverflow
Solution 2 - HtmlMartinView Answer on Stackoverflow
Solution 3 - HtmlQuentinView Answer on Stackoverflow
Solution 4 - HtmlNasruddinView Answer on Stackoverflow
Solution 5 - HtmlTiagoView Answer on Stackoverflow
Solution 6 - HtmlAndrew W.View Answer on Stackoverflow
Solution 7 - HtmlericmotilView Answer on Stackoverflow
Solution 8 - Htmluser3242943View Answer on Stackoverflow
Solution 9 - Htmldev_doctorView Answer on Stackoverflow
Solution 10 - HtmlLucas MatosView Answer on Stackoverflow
Solution 11 - HtmlSanthoshView Answer on Stackoverflow
Solution 12 - HtmlRichard StimsonView Answer on Stackoverflow
Solution 13 - HtmlWill BudreauView Answer on Stackoverflow
Solution 14 - HtmlJkarView Answer on Stackoverflow