In this article, you’ll learn how to open a URL in a new tab using Javascript. In HTML, we used the anchor tag to open URLs in a new tab in an elementary and straightforward manner. Sometimes, we need to do the same things using Javascript. In this case, you can use the window.open()
method which proves to be helpful.
The window.open()
method is used to open a new browser window or a new tab depending on the browser setting and the parameter values. You can use _blank
value in the second parameter of the window.open()
method to open the URL in the new tab or in the new window using JavaScript.
Here is an example to open a URL in a new tab using Javascript.
window.open("https://www.tutorialsrack.com", "_blank");
I hope this article will help you to understand how to open a URL in a new tab using Javascript.
Share your valuable feedback, please post your comment at the bottom of this article. Thank you!
Comments