user6937251
user6937251

Reputation:

Event listener across tabs

I have two windows: window A and window B.

window A and window B are active on the same Web-browser.

window A contains a script.

Questions:

Is it possible for window A to listen to events that are happening in windows B such as keyup?

Please provide some explanation.

Upvotes: 0

Views: 3129

Answers (3)

siva mirrappalli
siva mirrappalli

Reputation: 21

Window A can listen to Window B events using sockets, checkout socket.io library. Where we need to emit an event and listen across all windows or specific windows can be possible using this library.

Upvotes: 0

David Ginanni
David Ginanni

Reputation: 1627

In window B you set a cookie and in window A you create a setTimeout function that every "x" milliseconds check if there are any new cookie.

Look at this: Javascript communication between browser tabs/windows

Upvotes: 1

Pavel Staselun
Pavel Staselun

Reputation: 2010

If window A is a parent of window B (A opened B) then it's possible to find the element and add event listener. Also you can use postMessage to communticate between windows.

Upvotes: 0

Related Questions