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

580
Visualizações
Browser tab knows when it has been duplicated

I want my browser tab to know when it has been duplicated.

The only similar solutions I've seen focus on just the duplicated tab knowing it's been duplicated or the original tab knowing it's been duplicated but this only works on Chrome.

Requirements:

  • Solution works on all modern browsers

Bonus if the solution:

  • Works on a version of Internet Explorer
  • Uses some native Angular functionality
over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

You can make use of Broadcast Channel API .

  1. Create a channel on load and broadcast the message
  2. use the onmessage event, capture the message and if it matches the initial one, broadcast another
  3. The duplicate tag will receive the second broadcast , while first tab receives the first broadcast

 const broadcast = new BroadcastChannel('test')
    broadcast.postMessage('I am First');
    broadcast.onmessage = (event) => {
      if (event.data === "I am First") {
        broadcast.postMessage(`Sorry! Already open`);
        alert("First Tab");
      }
      if (event.data === `Sorry! Already open`) {
        alert("Duplicate Tab");
      }
    };

over 4 years ago · Santiago Trujillo 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