Use window.open():

<a onclick="window.open(document.URL, '_blank', 'location=yes,height=570,width=520,scrollbars=yes,status=yes');">
  Share Page
</a>

This will create a link titled Share Page which opens the current url in a new window with a height of 570 and width of 520.

Answer from citruspi on Stack Overflow
🌐
TutorialsPoint
tutorialspoint.com › how-to-open-link-in-a-new-window-javascript
How to open link in a new window using JavaScript?
Below are the Examples to Open Link in a New Window · In this example we will open a new window with the defined window dimension. <!DOCTYPE html> <html> <body style="text-align:center;"> <p> Click Button To Open New Window </p> <button onclick="newwindow()"> Open </button> <script> function newwindow() { window.open("https://www.tutorialspoint.com/css/index.htm", "", "width=500, height=500"); } </script> </body> </html>
🌐
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.
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › how-to-open-url-in-a-new-window-using-javascript
How to open URL in a new window using JavaScript? - GeeksforGeeks
August 21, 2025 - This approach is straightforward and commonly used for external links, enhancing user experience by keeping the current page intact. Example: Use Anchor tag to open URL in a new window using JavaScript.
🌐
Medium
medium.com › @progmacattack › open-a-link-in-a-new-window-with-vanilla-javascript-1e8298612b8f
Vanilla Javascript: Open a link in a new window | by Adam S. | Medium
November 16, 2015 - var portfolioLinks = document.getElementById("portfolio-details"); portfolioLinks.addEventListener("click",portfolioLinkClicked,false) }//if a portfolio link is clicked, open in new window function portfolioLinkClicked(e) { var url = e.target.href; window.open(url,"","titlebar=no"); } There are a lot of customization options from here. ... <a href=”http://codepen.io/asickmiller/full/KdXXZE/" onclick=”return false”>Wikipedia Search</a><br /> Well that keeps the html from loading the link at all. What I mean is, since Javascript is loading the link from the href string in a new window, we don’t want our HTML doing the same thing in the background.
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › how-to-open-url-in-new-tab-using-javascript
How to Open URL in New Tab using JavaScript? - GeeksforGeeks
In this example · When clicked, it runs the NewTab() function. window.open("https://www.geeksforgeeks.org////", "_blank"); opens the GeeksforGeeks website in a new tab. Here are the applications of opening URLs in new tabs: External Links: ...
Published   August 21, 2025
🌐
W3Docs
w3docs.com › html
How to Open Hyperlink in a New Window
There is another way of opening a hyperlink in a new tab by using the JavaScript window.open function with the onclick event attribute like this: ... <!DOCTYPE html> <html> <head> <title>Title of the document</title> <style> .link:hover { ...
🌐
W3Schools
w3schools.com › jsref › met_win_open.asp
Window open() Method
Animation Events Clipboard Events Drag Events Events Focus Events HashChange Events Input Events Keyboard Events Mouse Events PageTransition Events PopState Events Progress Events Storage Events Touch Events Transition Events Ui Events Wheel Events HTML Event Properties · altKey (Mouse) altKey (Key) animationName bubbles button buttons cancelable charCode clientX clientY code ctrlKey (Mouse) ctrlKey (Key) currentTarget data defaultPrevented deltaX deltaY deltaZ deltaMode detail elapsedTime elapsedTime eventPhase inputType isTrusted key keyCode location metaKey (Mouse) metaKey (Key) newURL oldURL offsetX offsetY pageX pageY persisted propertyName relatedTarget relatedTarget screenX screenY shiftKey (Mouse) shiftKey (Key) target targetTouches timeStamp touches type which (Mouse) which (Key) view HTML Event Methods
Find elsewhere
🌐
ThoughtCo
thoughtco.com › open-link-new-window-javascript-3468859
How to Open a Link in a New Window Using JavaScript
April 14, 2020 - If you don't specify a URL, a new blank window opens: window.open("https://www.somewebsite.com", "_blank", "toolbar=yes,top=500,left=500,width=400,height=400"); The name parameter sets the target for the URL.
🌐
RapidTables
rapidtables.com › web › html › link › html-link-new-window.html
HTML link in a new window
<a href="../html-link.htm" target="_blank">Open page in new window</a> ... 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', ...
🌐
Educative
educative.io › answers › how-to-open-a-link-in-a-new-tab-with-html-and-javascript
How to open a link in a new tab with HTML and JavaScript
We use _blank to tell the window.open() method to open the link in a new tab. We can use HTML to open links in new tabs when adding simple links in static content, such as articles or navigation menus.
🌐
Microsoft Learn
learn.microsoft.com › en-us › answers › questions › 4765921 › creating-links-that-open-in-a-new-window
creating links that open in a new window.__ - Microsoft Q&A
(Insert > html code fragment) Here is the code snippet again: <script language="JavaScript" type="text/javascript"> function Show(Url, Name, Features) { window.open(Url, Name, Features); } ... Move the code fragment box off to a corner or empty ...
🌐
CSS-Tricks
css-tricks.com › snippets › html › open-link-in-a-new-window
Open Link in a New Window | CSS-Tricks
May 14, 2013 - Here’s more people with the same issue stackoverflow link ... has usually always worked on every browser. target=”new” not so much however but target=”_new” usually does. ... Hello HarBek… You can use target=”_anything” ….This is not complusory to use “new” after underscore….because this is not a keyword..Any browser can take it as command to open new window.. :) ... This topic is missing something important. Is there a way using CSS and HTML to open internal links in same window and external links in new window?
🌐
SitePoint
sitepoint.com › javascript
Using html button + javascript function to open links in new window - JavaScript - SitePoint Forums | Web Development & Design Community
August 1, 2018 - Hi all, Im trying to set up a function where once a html button is pressed, a function checks a variable and redirects a link to a new window if the value comes back positive. This is the function I’m trying to get going: function launchTask() { window.open("https://www.google.com","_blank"); } and the button button type=“button” onclick=“LaunchTask()” Theres probably a basic solution i’m not seeing, can somebody help?
🌐
Delft Stack
delftstack.com › home › howto › javascript › open url in a new window javascript
How to Open URL in a New Window With JavaScript | Delft Stack
March 14, 2025 - This tutorial demonstrates how to open a URL in a new window using JavaScript. Learn various methods including window.open(), anchor tags, and event listeners with clear examples. Enhance your web development skills and improve user experience with these techniques.
🌐
Squash
squash.io › how-to-open-a-url-in-a-new-tab-using-javascript
How to Open a URL in a New Tab Using JavaScript
To open a URL in a new tab using JavaScript, you can use the window.open() method. This method opens a new browser window or tab, depending on the user's browser settings.
🌐
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 ...
🌐
PHPpot
phppot.com › javascript › javascript-how-to-open-url-in-new-tab
JavaScript – How to Open URL in New Tab - PHPpot
This is absolutely for beginners. There are three ways to open a URL in a new tab. HTML anchor tags with target=_blank attribute. JavaScript window.open() to set hyperlink and target.
🌐
University of New Mexico
unm.edu › ~tbeach › IT145 › week13 › example10.html
Javascript Opening Windows
Let's not specify the extra settings and let it open in a new window with this link. <p>Let's not specify the extra settings and let it open in a new window with this <a href="javascript:location='example10.html'; window.open('../index.html', 'demo2')">link</a>.</p>