How to insert target _Blank in this java script code?

Asked

Viewed 200 times

-4

I would appreciate help to open the pages in a new tab. I have this js code below, where and how to place the target _blank?

if(result[i]['link']=="") {
  htmlToInsert += "<td><a class='butaoJogar' href='"+urlJogar+"?campanha="+result[i]['betcodecampanha']+"'>Jogar</a></td>";
}
else {
  htmlToInsert += "<td><a class='butaoJogar' href='"+result[i]['link']+"'>Jogar</a></td>";
}
  • Forgive my ignorance, but separador would be the same as aba in the Portuguese language spoken in Brazil?

  • In the Portuguese language of Brazil, when it comes to internet browsers this here is a tab. The same as tab in the English language. That’s what we’re talking about or the subject is Iframe? Beforehand apologizing for the language disorder.

  • This is to say that we should call the right name so as not to create doubts. In this case the word of origin has been modified in Brazil, it should always be called separator and not a tab. In English, tab is an abbreviation, it does not mean tab only but separation tab.

  • I guess you didn’t understand, I just wanted to understand your problem to offer you the best solution. Nothing else.

  • 1

    OK Augusto Vasques, I understood and thank you very much. But I took the opportunity to clarify the literacy, where I am involved professionally.

  • I appreciate the hermeneutic class but it’s out of scope. The goal of the site is to provide help with fewer possible interactions between users. A yes or no would have sufficed,

  • Okay... you’re right, Augusto Vasques. Maybe this is due to a certain saturation. From now on it won’t happen, I’ll just answer yes or no, etc.

Show 2 more comments

1 answer

1


target="_blank" can be added to links as follows: <a href="https://www.w3schools.com" target="_blank">Visit W3Schools</a>.

In your example, it would be:

if(result[i]['link']=="") {
  htmlToInsert += "<td><a class='butaoJogar' href='"+urlJogar+"?campanha="+result[i]['betcodecampanha']+"' target='_blank'>Jogar</a></td>";
}
else {
  htmlToInsert += "<td><a class='butaoJogar' href='"+result[i]['link']+"' target='_blank'>Jogar</a></td>";
}

For more information you can consult this link.

  • I’m having trouble decoding the question, but I don’t think that’s it. I think the AP just wants to know how to open a link in a new tab and not in a new window. And if that is the question it would be only by modifying the browser settings.

  • Ps: It was not I who negatived, I have no information to negative or positive. As I have already said I am with doubts of my interpretation.

  • But Blank already opens in a tab, doesn’t it? Now that you mention it, I thought he might want a "pop up".

  • 1

    People are really mysterious... They don’t like to talk about why -1 :)

  • 1

    Only opens a new tab if it is configured by the user. It is the default behavior, but there are many people who make the change.

  • Hello, I want to open the page in a new window or tab, for now opens in the same window or tab.

  • I left +1 because I understood that AP just wants you to open a page regardless of where. You are correct.

  • @Meirelles, so was the answer helpful? Make sure you’re not changing " and '. As you are in a string it is necessary to make Escaping out use simple quotes.

  • Solved, it’s already working. There was even an error in the quotes " '. Thank you Augusto Vasques and tvDias.

Show 4 more comments

Browser other questions tagged

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