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

157
Visualizações
Getting sessionStorage.getItem(...).focus is not a function error

I have the following code,

var newTab;
var url = uniqueUrlEveryTime;

if (!sessionStorage.getItem(url)) {
    newTab = window.open(url, '_blank');
    sessionStorage.setItem(url, newTab);
    newTab.focus();
}
else {
    sessionStorage.getItem(url).focus();
}

When the Url is present in the sessionStorage, I am trying to get the newTab object from sessionStorage and set its focus, but it is giving me an error. What am I doing wrong?

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

0

You set the session storage to be the url of the tab. Now you need to run through your tabs and check if the one of them has that url and then set .focus()

Some theoretical code below because I am not sure what your html for the tabs looks like

const tabUrl = sessionStorage.getItem(url)

if(tabUrl === newTab.url){newTab.focus() }
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