Randomblue
Randomblue

Reputation: 116263

How can I establish communication between same-origin tabs?

The same-origin policy dictates that scripts on different pages are only allowed to access each other if and only if the pages which executed them are at locations with the same protocol, port number, and host.

Given two independently opened pages in the same origin, is it possible for those two pages to share scripts?

Upvotes: 4

Views: 111

Answers (1)

Niet the Dark Absol
Niet the Dark Absol

Reputation: 324600

localStorage is common to all open instances of an origin, and the storage event is fired in all of those instances when just one of them changes the localStorage. In this way, it is possible to identify and send messages to other instances of your site.

Upvotes: 6

Related Questions