Search code examples
javascripthtmlwindowhref

How to open a link in a new window?


I'm trying to make a window popup with my link using HTML & JS.

So far I've managed to get this <a href="myLink" target="_blank" rel="noreferrer">myText</a>, but this just makes the link open in a new tab.


Solution

  • This is how to open a link in a new window.

    <a href="myLink" 
     target="popup" 
     onclick="window.open('myLink','popup','width=600,height=600'); return false;">
       Open Link in Popup
    </a>
    

    Always remember the sometimes that user configures their browsers to block all new tabs and windows (at least this is what I do), to avoid annoying advertisements and click baits links.