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
🌐
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
🌐
W3Schools
w3schools.com › cssref › css3_pr_target-new.php
CSS target-new property
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.
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;}

🌐
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 ...
Find elsewhere
🌐
W3Schools
w3schools.com › html › html_links.asp
HTML Links Hyperlinks
_self - Default. Opens the document in the same window/tab as it was clicked · _blank - Opens the document in a new window or tab
🌐
CSS-Tricks
css-tricks.com › snippets › html › open-link-in-a-new-window
Open Link in a New Window | CSS-Tricks
May 14, 2013 - I’d say it’s a bad practice. Because if I want to open link in new window, jsut press shift+mouse key. Or middle button (to open in new tab).
🌐
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
By default, it opens the target URL in the same tab. This default behavior can be changed in one of two ways · The simplest way is using the target attribute. The '_blank' tells the browser to use a new window or tab.
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › API › Window › open
Window: open() method - Web APIs | MDN
The open() method of the Window interface loads a specified resource into a new or existing browsing context (that is, a tab, a window, or an iframe) under a specified name.
🌐
HTML.com
html.com › attributes › a-target
How To Use The <a> To Make Links & Open Them Where You Want! »
January 11, 2019 - If target="_blank", the linked document will open in a new tab or (on older browsers) a new window.
🌐
W3Schools
w3schools.com › tags › att_a_target.asp
HTML a target Attribute
<!--> <!DOCTYPE> <a> <abbr> <acronym> <address> <applet> <area> <article> <aside> <audio> <b> <base> <basefont> <bdi> <bdo> <big> <blockquote> <body> <br> <button> <canvas> <caption> <center> <cite> <code> <col> <colgroup> <data> <datalist> <dd> <del> <details> <dfn> <dialog> <dir> <div> <dl> <dt> <em> <embed> <fieldset> <figcaption> <figure> <font> <footer> <form> <frame> <frameset> <h1> - <h6> <head> <header> <hgroup> <hr> <html> <i> <iframe> <img> <input> <ins> <kbd> <label> <legend> <li> <link> <main> <map> <mark> <menu> <meta> <meter> <nav> <noframes> <noscript> <object> <ol> <optgroup> <
🌐
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.
🌐
Equalize Digital
equalizedigital.com › home › link opens new window or tab
Link Opens New Window or Tab
August 28, 2025 - Links that open new windows or tabs include target="_blank" in the <a> tag, which tells the browser to open the new window or tab rather than following the link in the current tab.
🌐
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 - The target attribute set to _blank, which tells the browser to open the link in a new tab/window, depending on the browser's settings, and