Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

155
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!