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

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

This question is related to html cross-browser tabs

The answer is


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


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.


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.


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.


No, there isn't.


I hope this will help you

window.open(url,'_newtab');


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>

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>

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


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.


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

target="_parent"


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


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

Examples related to html

Embed ruby within URL : Middleman Blog Please help me convert this script to a simple image slider Generating a list of pages (not posts) without the index file Why there is this "clear" class before footer? Is it possible to change the content HTML5 alert messages? Getting all files in directory with ajax DevTools failed to load SourceMap: Could not load content for chrome-extension How to set width of mat-table column in angular? How to open a link in new tab using angular? ERROR Error: Uncaught (in promise), Cannot match any routes. URL Segment

Examples related to cross-browser

Show datalist labels but submit the actual value Stupid error: Failed to load resource: net::ERR_CACHE_MISS Click to call html How to Detect Browser Back Button event - Cross Browser How can I make window.showmodaldialog work in chrome 37? Cross-browser custom styling for file upload button Flexbox and Internet Explorer 11 (display:flex in <html>?) browser sessionStorage. share between tabs? How to know whether refresh button or browser back button is clicked in Firefox CSS Custom Dropdown Select that works across all browsers IE7+ FF Webkit

Examples related to tabs

Visual Studio Code - Convert spaces to tabs Sublime Text 3, convert spaces to tabs Bootstrap 3: Keep selected tab on page refresh Change tab bar tint color on iOS 7 Stacked Tabs in Bootstrap 3 C++ printing spaces or tabs given a user input integer Open link in new tab or window How to make a new line or tab in <string> XML (eclipse/android)? Find Active Tab using jQuery and Twitter Bootstrap How to make the tab character 4 spaces instead of 8 spaces in nano?