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

130
Visualizações
Is there any way to shift to previous browser tab using javascript?

Im working on a VBCS application and i have a requirement to download files onto a new tab.

Im running an application, and after a few operations I end up at the last tab (circled in black). I need to close the red circled tab because it is a duplicate of the blue circled tab. Is there any way i can go back to the red tab and call

window.close()

on it? All the tabs are being opened through my application only. IS it even possible to navigate back to the tab? Also i cannot close the blue circled tab because even though the red circled tab is a dulicate of it, the red tab is reloading the page and the blue tab is already loaded page.

Any help is very much appreciated. Thanks.

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

0

You can communicate between the tabs using localStorage (actually there might be even a better API for this BroadcastChannel ). Anyway, this is a sketch of a solution which is open for some bugs but if you like it , it can be improved.

<h2>page 1</h2>
<button onclick="close_others();">close others</button>
<script>
    window.id = Math.random();
    var key = "close-but-me"

    function close_others() {
        localStorage.setItem(key, window.id);
        window.setTimeout(function() {
            localStorage.removeItem(key);
        }, 2000)
    }

    setInterval(function() {
        console.log(localStorage.getItem(key))
        if (localStorage.getItem(key) && localStorage.getItem(key)!=window.id) {
            window.close();
        } 
    }, 1000)
</script>
<h2>page 2 - SAME code</h2>

<button onclick="close_others();">close others</button>
<script>
    window.id = Math.random();
    var key = "close-but-me"

    function close_others() {
        localStorage.setItem(key, window.id);
        window.setTimeout(function() {
            localStorage.removeItem(key);
        }, 2000)
    }

    setInterval(function() {
        console.log(localStorage.getItem(key))
        if (localStorage.getItem(key) && localStorage.getItem(key)!=window.id) {
            window.close();
        } 
    }, 1000)
</script>
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