Home > Enterprise >  Open new tab without rewrite previous open tab but open new one
Open new tab without rewrite previous open tab but open new one

Time:11-18

I google many times for looking for a way to open new tab on link click. If I click on link this javascript snippet open new tab and it's perfect, but if I click again new tab take focus and replaced with new content. I don't want this.

$('body').on('click', 'a.viewTextAndAnnotations', function(e) {
      e.preventDefault();
      var fullUrl = "https://www.example.com";
      window.open(fullUrl,'_newtab');
});

I would like that in second click user open second tab.

CodePudding user response:

Please try this.

 function openWindow( url )
    {
      window.open(url, '_blank');
      window.focus();
    }

<a href="http://www.example.com/" onclick="javascript:openWindow(this.href);return false;">Click Me</a>
  • Related