Target='_blank' to show in new window, NOT new tab, possible?
You cannot control this - it's entirely at the discretion of the user-agent; which is the point, after all. All you can specify is that the page be opened in a different viewpane context, and it's up to the user to decide how they want your window to take up their screen space/taskbar list/Alt-Tab shortcuts etc.
In fact I'd go even further and say that if at all possible you should avoid opening up a new tab/window at all. I know that I get a little annoyed when websites do this, and it feels a bit clunky and 1990s what with all the Ajax and floating divs and magic we have nowadays.
Target _blank not opening new window
Your syntax for the target
attribute is correct, but browsers need not honor it. They may interpret it as opening the destination in a new tab rather than new window, or they may completely ignore the attribute. Browsers have settings for such issues. Moreover, opening of new windows may be prevented by browser plugins (typically designed to prevent annoying advertisements).
There’s little you can do about this as an author. You might consider opening a new window with JavaScript instead, cf. to the accepted answer to target="_blank" is not working in firefox?, but browsers may be even more reluctant to let pages open new windows that way than via target
.
HTML: how to force links to open in a new tab, not new window
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.
Make a link open a new window (not tab)
With pure HTML you can't influence this - every modern browser (= the user) has complete control over this behavior because it has been misused a lot in the past...
HTML option
You can open a new window (HTML4) or a new browsing context (HTML5). Browsing context in modern browsers is mostly "new tab" instead of "new window". You have no influence on that, and you can't "force" modern browsers to open a new window.
In order to do this, use the anchor element's attribute target
[1]. The value you are looking for is _blank
[2].
<a href="www.example.com/example.html" target="_blank">link text</a>
JavaScript option
Forcing a new window is possible via javascript - see Ievgen's excellent answer below for a javascript solution.
(!) However, be aware, that opening windows via javascript (if not done in the onclick event from an anchor element) are subject to getting blocked by popup blockers!
[1] This attribute dates back to the times when browsers did not have tabs and using framesets was state of the art. In the meantime, the functionality of this attribute has slightly changed (see MDN Docu)
[2] There are some other values which do not make much sense anymore (because they were designed with framesets in mind) like _parent
, _self
or _top
.
target=_blank opens a new window in IE9, instead of a new tab
HTML and JavaScript provide no means to say if a new "window" should be a full window, or a tab, or whatever you want to call the Mobile Safari multiple views interface.
So you live with it.
Related Topics
Detect Click Event Inside Iframe
Mui Createtheme Is Not Properly Passing Theme to Mui Components
Ckeditor: Class or Id for Editor Body
CSS Float Elements with Unequal Heights Left and Up in Grid
Transforms Are Added...Endlessly
Angularjs:Difference Between the $Observe and $Watch Methods
JavaScript Es6 Computational/Time Complexity of Collections
Cross-Platform, Cross-Browser Way to Play Sound from JavaScript
JavaScript Regexp + Word Boundaries + Unicode Characters
How to Block Website from Loading in Iframe
Safari: Absolutely Positioned Divs Not Moving When Updated via Dom
Add CSS Styled Marker to Google Maps
How to Check Element's Visibility via JavaScript
Changing Background Color of Div on Scroll
How to Check for Null Values in JavaScript