That will open a new window, not tab (with JavaScript, but quite laconically):

<a href="print.html"  
    onclick="window.open('print.html', 
                         'newwindow', 
                         'width=300,height=250'); 
              return false;"
 >Print</a>
Answer from Ievgen on Stack Overflow
🌐
OutSystems
outsystems.com › forums › discussion › 65977 › open-link-in-a-new-window-not-tab
Open link in a new window (NOT TAB) | OutSystems
I have a link on my page, and I want it to open it in a new window (not a new tab) when clicking it. Currently, this link points to a new screen action, and in this new screen action I have a RunJavaScript server action with the following script: · However, it still open the link in new tab ...
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › API › Window › open
Window: open() method - Web APIs | MDN
Popups don't have a menu toolbar, whereas new tabs use the user interface of the browser window; therefore, many users prefer tab-browsing because the interface remains stable. Avoid <a href="#" onclick="window.open(…);"> or <a href="javascript:window\.open(…)" …>. These bogus href values cause unexpected behavior when copying/dragging links, opening links in a new tab/window, bookmarking, or when JavaScript is loading, errors, or is disabled.
Top answer
1 of 7
1

i think yo want to open a completely new window on clicking a link.in other words u want a popup.try the following code.

<script language="javascript" type="text/javascript">
function popitup(url) {
newwindow=window.open(url,'name','height=200,width=150');
if (window.focus) {newwindow.focus()}
return false;
   }

<a href="popupex.html" onclick="return popitup('popupex.html')">Link to popup</a>
2 of 7
1

This works in theory but it will depend on the preferences set in the browser. Now a days you can fake a new window by using div's and Layers. Is there anyway to implement a layer that hides what is behind it.

JavaScript:

function getElementsByClass( searchClass, domNode, tagName) { 
    if (domNode == null) domNode = document;
    if (tagName == null) tagName = '*';
    var el = new Array();
    var tags = domNode.getElementsByTagName(tagName);
    var tcl = " "+searchClass+" ";
    for(i=0,j=0; i<tags.length; i++) { 
    var test = " " + tags[i].className + " ";
    if (test.indexOf(tcl) != -1) 
        el[j++] = tags[i];
} 
return el;
}
// paste getElementsByClass function (see above) here 

function showtab(tabname) 
{ 
// hide every element with class 'box1'  
var tabs = getElementsByClass('box1');
for(i=0; i<tabs.length; i++) {
    tabs[i].style.display = 'none';
    //tabs[i].style.visibility = 'hidden';
}
// hide every element with class 'box1'      
var tabs2 = getElementsByClass('myStyle');
for(i=0; i<tabs2.length; i++) {
    tabs2[i].style.display = 'none';
    //tabs2[i].style.visibility = 'hidden';
}

document.getElementById(tabname).style.display='block';
//document.getElementById(tabname).style.visibility='visible';
// show element with given tabname 
} 

function showsubtab(tabname)
{
//hide every element with class 'myStyle'
var tabs = getElementsByClass('myStyle');
for(i=0; i<tabs.length; i++) {
    tabs[i].style.display = 'none';
    //tabs[i].style.visibility = 'hidden';
}
document.getElementById(tabname).style.display='block';
//document.getElementById(tabname).style.visibility='visible';
}

if (window.addEventListener) { // Mozilla, Netscape, Firefox
window.addEventListener('load', showmessage, false);
} else if (window.attachEvent) { // IE
window.attachEvent('onload', showmessage);
}

function showmessage() {
document.getElementById('box').style.display='block';
document.getElementById('div1').style.backgroundColor='grey';
document.getElementById('div1').style.opacity = 0.2;
document.documentElement.style.overflow = "hidden"; //firefox, chrome
document.body.scroll = "no"; // ie only
var bodyLayer = document.getElementById('div1');
DisableLinks(bodyLayer);
}
function hidemessage() {
document.getElementById('box').style.display='none';
document.getElementById('div1').style.backgroundColor='transparent';
document.getElementById('div1').style.opacity = 1.0;
document.documentElement.style.overflow = 'auto';  // firefox, chrome
    document.body.scroll = "yes"; // ie only
var bodyLayer = document.getElementById('div1');
EnableLinks(bodyLayer);
}

function DisableLinks(dom) {
if(undefined != dom){
    links=dom.getElementsByTagName('A');
} else {
    links=document.getElementsByTagName('A');
}

for(var i=0; i<links.length; i++) {
    links[i].style.pointerEvents="none";
}
}

function EnableLinks(dom) {
if(undefined != dom){
    links=dom.getElementsByTagName('A');
} else {
    links=document.getElementsByTagName('A');
}

for(var i=0; i<links.length; i++) {
    links[i].style.pointerEvents="auto";
}
}

HTML

<div id="box">
<section id="close">
<section id="title">Important Site Message</section>
<section id="button"><a href="#" onClick="hidemessage();">[X]</a>&nbsp;</section>
</section>
<!--Body of the Message-->
</div>

CSS #box {position: absolute; top: 50%; left: 50%; height: 15.625em; width: 25em; background-color:#FFF; margin-top: -7.8125em; margin-left: -12.5em; display: none; overflow: auto; border-color:#000; border-style:ridge; border-width:medium; z-index: 3; color: #000;} #close {border-bottom: inset thick #CCC; background-color: #000; width: inherit; height: 1.2em; color: #FFF; position: fixed;} #close a:visited {color: #FFF;} #close a:hover {color: red; text-decoration:none;} #close #title {text-align: center; font-weight:bold; width: 90%; padding: 1 1 1 1; clear: left; float: left; background-color:#000; color:#FFF;} #close #button {text-align: right; padding: 1 1 1 1; width: 10%; clear: right; float: right; background-color: #000; color: #FFF;}

🌐
CSS-Tricks
css-tricks.com › snippets › html › open-link-in-a-new-window
Open Link in a New Window | CSS-Tricks
May 14, 2013 - Because if I want to open link in new window, jsut press shift+mouse key. Or middle button (to open in new tab). ... I’d say it’s the best practice to use target=”_blank”, because it simply works.
🌐
W3Schools
w3schools.com › jsref › met_win_open.asp
Window open() Method
The open() method opens a new browser window, or a new tab, depending on your browser settings and the parameter values.
Find elsewhere
🌐
w3tutorials
w3tutorials.net › blog › how-to-open-link-in-a-new-tab-in-html
How to Open a Link in a New Tab in HTML (Without JavaScript) — w3tutorials.net
The target="_blank" value tells the browser to load the linked URL in a new browsing context (typically a new tab, though some browsers may use a new window depending on user settings).
🌐
W3Docs
w3docs.com › html
How to Open Hyperlink in a New Window
To open a link in a new window, you need to add the target="_blank" attribute to your anchor link, like the following. <!DOCTYPE html> <html> <head> <title>Title of the document</title> </head> <body> <h1>Hyperlink Example</h1> <p> This <a ...
🌐
Educative
educative.io › answers › how-to-open-hyperlinks-in-a-new-window-in-html
How to open hyperlinks in a new window in HTML
However, most browsers default to using a new tab instead of a new window. ... In JavaScript, the window object represents the browser window. The open() method of the window object can be used to create a new window. ... On line 6, window.open is used with the onclick attribute within the <a> tag. Parameters passed to window.open are as follows: this.href: It refers to href , the URL already specified in <a> tag. ... Lastly, return false; makes sure the original window is not redirected.
🌐
HTML.com
html.com › attributes › a-target
How To Use The <a> To Make Links & Open Them Where You Want! »
January 11, 2019 - The target attribute specifies where the linked document will open when the link is clicked. The default is the current window. If target="_blank", the linked document will open in a new tab or (on older browsers) a new window.
🌐
freeCodeCamp
freecodecamp.org › news › how-to-use-html-to-open-link-in-new-tab
How to Use HTML to Open a Link in a New Tab
September 8, 2020 - You just need an anchor (<a>) element with three important attributes: The href attribute set to the URL of the page you want to link to, The target attribute set to _blank, which tells the browser to open the link in a new tab/window, depending ...
🌐
RapidTables
rapidtables.com › web › html › link › html-link-new-window.html
HTML link in a new window
You can't set whether the link will be opened in a new window or new tab. It depends on the browser's settings. In order to open a link in a new window, add Javascript command onclick="window.open('text-link.htm', 'name','width=600,height=400') inside the <a> tag:
🌐
W3Schools
w3schools.com › tags › tryit.asp
W3Schools online HTML editor
The W3Schools online code editor allows you to edit code and view the result in your browser
🌐
GeeksforGeeks
geeksforgeeks.org › how-to-open-url-in-a-new-window-using-javascript
How to open URL in a new window using JavaScript? | GeeksforGeeks
August 1, 2024 - To open a link without clicking on it we can use the onmouseover method of JavaScript. The link will open when the mouse moves over the text. It returns a newly created window, or NULL if the call gets failed.
🌐
Zipy
zipy.ai › blog › how-to-open-a-url-in-a-new-tab-and-not-a-new-window
how to open a url in a new tab (and not a new window)
April 12, 2024 - A common yet critical feature is opening a URL in a new tab rather than in a new window. This action not only keeps the user's current context intact but also adheres to the modern web navigation patterns that users have come to expect. In this comprehensive guide, we'll explore how to achieve this using JavaScript...