How to Open URL in New Tab using JavaScript? Last Updated : 13 Sep, 2024 Comments Improve Suggest changes Like Article Like Report HTML anchor tag is used to open URLs in a new tab using the target="_blank" attribute. In JavaScript, we have an inbuilt method window.open() which is used to open a new browser window or new tab depending on the browser settings. Using window.open() MethodTo open a new tab, we have to use _blank in the second parameter of the window.open() method.The return value of window.open() is a reference to the newly created window or tab or null if it failed.Do not add a third parameter to it as it will result in the opening of a new window rather than a tabSyntax:window.open(URL, '_blank');Example: In this example, we create a button that, when clicked, uses JavaScript (window.open) to open "geeksforgeeks.org" in a new browser tab, maintaining the current page's context. HTML <html> <head> <title>Open URL in New Tab </title> </head> <body> <p> Click the button to open <b> geeksforgeeks.org </b> in new tab </p> <button onclick="NewTab()"> Open Geeksforgeeks </button> <script> function NewTab() { window.open( "https://www.geeksforgeeks.org", "_blank"); } </script> </body> </html> Output: Important Notes:The return value of window.open() is a reference to the newly created window or tab. It returns null if it fails to open the new tab.Avoid adding a third parameter to the window.open() method because it could result in a new window instead of a tab.Supported Browsers:The browsers are supported by the window.open() method are listed below:Google ChromeEdge FirefoxOperaSafari Comment More infoAdvertise with us Next Article How to Open URL in New Tab using JavaScript? H harshcooldude700 Follow Improve Article Tags : JavaScript Web Technologies Similar Reads How to open URL in a new window using JavaScript? In HTML, the anchor tag (<a>) is used to open new windows and tabs in a very straightforward manner. However, there are situations where you need to achieve the same functionality using JavaScript. This is where the window.open() method becomes useful.The window.open() method is used to open a 3 min read How to Open URL in New Tab using Angular ? In this article, we will learn How to open a link in a new tab using Angular. A Link is a connection from one web page to another web page. Generally, the anchor tag can be used to open URLs in a new tab in an elementary and straightforward manner. However, the window.open() method can also be utili 2 min read How to get URL Parameters using JavaScript ? To get URL parameters using JavaScript means extracting the query string values from a URL. URL parameters, found after the ? in a URL, pass data like search terms or user information. JavaScript can parse these parameters, allowing you to programmatically access or manipulate their values.For getti 3 min read How to replace plain URL with link using JavaScript ? Given a plane URL, the task is to replace the plain URLs with the links. This problem can be solved with the help of Regular Expressions. Approach:Â Using RegExp and replace() MethodRegExp - This looks for the URL in the provided text.This RegExp parses the URL and puts the address to the $1 variable 2 min read How To Get URL And URL Parts In JavaScript? In web development, working with URLs is a common task. Whether we need to extract parts of a URL or manipulate the URL for navigation, JavaScript provides multiple approaches to access and modify URL parts. we will explore different approaches to retrieve the full URL and its various components.The 3 min read How to redirect to a relative URL in JavaScript? To redirect to a relative URL in JavaScript, you could use window.location.href. It is a property in JavaScript that represents the complete URL of the current page. It can be used to get the current URL or to navigate to a new URL by assigning a new URL to it. Approach HTML Structure:The HTML file 2 min read How to Get the Current URL using JavaScript? Here are two different methods to get the current URL in JavaScript.1. Using Document.URL PropertyThe DOM URL property in HTML is used to return a string that contains the complete URL of the current document. The string also includes the HTTP protocol such as ( http://).Syntaxdocument.URLReturn Val 1 min read How to add a parameter to the URL in JavaScript ? Given a URL the task is to add parameter (name & value) to the URL using JavaScript. URL.searchParams: This read-only property of the URL interface returns a URLSearchParams object providing access to the GET-decoded query arguments in the URL. Table of Content Using the append methodUsing set m 2 min read How to modify URL without reloading the page using JavaScript ? In this article, we are going to see how to modify URL without reloading the page using JavaScript Below are the methods to modify the URL without reloading the page using JavaScript: Table of Content Replacing the current state with replaceState() MethodAdding a new state with pushState() MethodMet 3 min read How to Get Browser to Navigate URL in JavaScript? As a web developer, you may need to navigate to a specific URL from your JavaScript code. This can be done by accessing the browser's window object and using one of the available methods for changing the current URL.In JavaScript, there are several approaches for navigating to a URL. The most common 4 min read Like