How to Open a Link in a New Tab with JavaScript
By Birtchum Thompson | March 24, 2020
Opening a link in a new tab with JavaScript is as simple as it is with the HTML <a> tag’s target attribute. In fact, it even uses "_blank" as the target for the new tab just like the HTML <a> tag.
The JavaScript window object is a representation of the browser window and provides some helpful functionality for the web. For opening a new tab, window’s open() function is used. The open() function must receive 2 arguments for our purpose: the URL to open and "_blank" as the second argument. The code should look similar the the example below.
JavaScript