Tudor
Tudor

Reputation: 1181

JS - What options are there for getting the used window from multiple windows?

I need to get the used window by a user . I am storing some data in cookies for a window each time the user is browsing it. I want to update this window data each time the user goes to another window .

The only option that came into my mind is by using the onClick event .

window onClick -> update coockie data with this window .

What other options are there ? Is there a window focus event or something like that ?

Upvotes: 0

Views: 23

Answers (1)

Amit Joki
Amit Joki

Reputation: 59252

Yes there is a window focus event.

window.onfocus = function(){
   // your code goes here
}

Upvotes: 1

Related Questions