Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Open new tab without rewrite previous open tab but open new one

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.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

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>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading