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

146
Visualizações
Move to tab but don't reload

I'm using the code below with window.open to open a new link (same origin) in a new tab. If a tab with the new link is already open, the open tab should be focused instead.

This is all working fine, the focused tab is however always refreshed when it gains focus by this. How can I stop the focused tab from refreshing?

window.open(`./${_id}`, `module_${_id}`);
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Check if the window is closed orelse use focus(), this should not refresh the page.

    var windowObject = null; // global variable
    
        function openURL(url) {
          if(windowObject == null || windowObject.closed) {
            windowObject= window.open(url);
          } else {
            windowObject.focus();
          }
        }

<button value="Check" onClick="openURL('https://www.google.com')"></button>
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