Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

148
Visualizações
Open to new window or tab on click

I am trying to make different countries in this map (http://jsfiddle.net/hansenmc/EnqP3/) open to a new tab or window. I am able to open in the same window without an issue using this code.

     onRegionClick: function (element, code, region) {
        
        
        if(code == 'il'){
window.open("www.mywebsite.com", "_blank");
}

When I use this code it opens in the same window and a new window simultaneously.

    onRegionClick: function (element, code, region) {
        
        
        if(code == 'us'){
window.open = "www.mywebsite.com, _blank";
}

Any help getting different countries to open into their own window would be greatly appreciated. I have tried solutions from other threads but none seem to work in this scenario.

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

You could use the Event object .preventDefault() method on windown.open().

about 4 years ago · Juan Pablo Isaza Relatório

0

window.open is a function, so it should be called instead of assigned to.

Instead of:

window.open = "www.mywebsite.com, _blank";

It should be:

window.open("www.mywebsite.com", "_blank");

Also, if you want the function open the URL correctly, it should include the http(s):// prefix, otherwise it will open a relative path from the current windows location in some browsers.

The full code in your case would be:

onRegionClick: function (element, code, region) {
    if(code == 'us'){
        window.open("www.mywebsite.com", "_blank");
    }
}

Shorter version:

onRegionClick(element, code, region) => {
    if(code == 'us')
        window.open("www.mywebsite.com", "_blank");
}

For a dynamic URL, something like the following would work:

onRegionClick(element, code, region) => {
    if(code == 'us')
        window.open(`www.mywebsite.com/${code}`, "_blank");
}
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda