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.
Top answer 1 of 5
320
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.
2 of 5
88
Just use window.open() function? The third parameter lets you specify window size.
Example
var strWindowFeatures = "location=yes,height=570,width=520,scrollbars=yes,status=yes";
var URL = "https://www.linkedin.com/cws/share?mini=true&url=" + location.href;
var win = window.open(URL, "_blank", strWindowFeatures);
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › API › Window › open
Window: open() method - Web APIs | MDN - Mozilla
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.
Using html button + javascript function to open links in new window - JavaScript - SitePoint Forums | Web Development & Design Community
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 goi… More on sitepoint.com
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 ... More on outsystems.com
creating links that open in a new window.__
When using publisher to create web sites, I cannot figure out how to embed a link that will open in a new window. Is there an option for that? More on learn.microsoft.com
How can I make a HTML a href hyperlink open a new window? - Stack Overflow
This is my code: test When you click it, it takes you to Yahoo b... More on stackoverflow.com
Videos
08:53
Opening New Windows or Tabs from JavaScript
01:38
How to Open a URL in a New Tab Using JavaScript & HTML - YouTube
01:05
How to Open Multiple Links in a New Window with JavaScript - YouTube
00:52
JavaScript Open Link in New Window - YouTube
Open Link in New Window using JavaScript
Open Link in New Tab using JavaScript - YouTube
TutorialsPoint
tutorialspoint.com › how-to-open-link-in-a-new-window-javascript
How to open link in a new window using JavaScript?
September 25, 2024 - <!DOCTYPE html> <html> <body> <p>Click Button To Open New Window</p> <button onclick="newwindow()">Click</button> <script> function newwindow() { window.open("https://www.tutorialspoint.com/javascript/index.htm", "_blank","toolbar=no,scrollbars=no,resizable=yes,top=500,left=500,width=400,height=400"); } </script> </body> </html>
GeeksforGeeks
geeksforgeeks.org › javascript › how-to-open-url-in-new-tab-using-javascript
How to Open URL in New Tab using JavaScript? - GeeksforGeeks
To open a URL in a new tab using JavaScript, we can use the window.open() method. The window.open() method is used to open a new browser window or tab. It can also be used to load a specific URL in a new tab.
Published August 21, 2025
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.
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
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.
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?
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 ...
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 - Squash.io
April 30, 2024 - 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.
Top answer 1 of 4
137
<a href="#" onClick="window.open('http://www.yahoo.com', '_blank')">test</a>
Easy as that.
Or without JS
<a href="http://yahoo.com" target="_blank">test</a>
2 of 4
5
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:
<a href="../html-link.htm" target="popup" onclick="window.open('../html-link.htm','name','width=600,height=400')">Open page in new window</a>