How to open link / url in new tab using JavaScript

Simple html ‘a>’ tag with attribute “_blank” provides an easy and simple way to open the linked URL in the new browser window, We mostly use this method for external link so that visitor couldn’t leave actual website. But sometime you need to open new tab using javascript, you can simply use following javascript function to open link in new tab.

Here I am going to use javascript function, Next use _blank in the second parameter of method to open a URL in a new tab using JavaScript. The following JavaScript code will open in a new tab or window of browser.

function openNewTab(url) {
  var win =, '_blank');
<span onclick="openNewTab('');">Click To Open My Public NoteBook</span>