How do I open this function url in new tab in random link option

Asked

Viewed 38 times

-1

links = new Array("<www.google.com","https://www.youtube.com/","portal.trademap.com.br");
tamanho = links.length;

nRand = Math.floor((Math.random() * tamanho ));

document.write ("<p><a href='"+links[nRand]+"' > BOTÃO </a></p>");

1 answer

1

To open a link in a new tab just add the property target="_Blank"

document.write ("<p><a target='_blank' href='"+links[nRand]+"' > BOTÃO </a></p>");

Browser other questions tagged

You are not signed in. Login or sign up in order to post.