Open multiple tabs on a JavaScript link

0

This script is to open two tabs or more in the browser on a single link. Clicking on the link opens only one new tab and the other is blocked as pop-ups by the browser. How do I not to block? Or is there another way to open multiple tabs in a single link?

<script language="JavaScript">
  function teste() {
    window.open("www.google.com.br", "_blank");
    window.open("www.gmail.com.br", "_blank");
}
</script>

<a href="javascript:teste();">Clique aqui para abrir as abas</a>
    
asked by anonymous 11.08.2016 / 17:09

1 answer

1

It is no longer possible to do this in recent browsers or it contains a popup blocker, so if window.open(...) does not return an object or returns undefined or null , you can know if the same popup has been blocked, however you will still not be able to open multiple tabs at the same time while your code block does not run.

if (!window.open("www.google.com.br", "_blank")) {
    /* Popup bloqueado. O que fazer? */
}

I think it's best not to try to open multiple tabs at the same time.

    
11.08.2016 / 18:23