How to open a URL in a new tab (and not a new window) using JavaScript?

JavascriptFront End TechnologyObject Oriented Programming

Opening of a URL in a new tab depends on the browser and the user's browser preferences. There is nothing you can do in code to force open a link strictly in a new tab.

However if you want the user to open it in either new tab or window(depending on their preferences) you can add the following attribute to the anchor() tag −


This will instruct the browser to leave the current page as is and open the link in a new tab/window.

Updated on 19-Sep-2019 06:51:31