1

Providing my limitations are the abilities of the browser and I have two web pages, is it possible to write javascript on one that changes tabs and executes some javascript on another page?

Is there any way for two tabs to communicate to each other outside the server?

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
alt
  • 13,357
  • 19
  • 80
  • 120

2 Answers2

2

You can only do this if:

  1. One tab opened the other.
  2. Both pages are served from the same domain.

The opener tab just needs to store a reference to the window object returned from window.open(), and the new tab can reference the parent through window.opener.

Waxen
  • 1,792
  • 2
  • 27
  • 27
1

If HTML5 SharedWorkers is an option, I would suggest using those.

Pages that reference the same worker and have the right callbacks can update instantaneously, be they different pages or different tabs. As long as they're in the same browser, it'll work.

Here's a tutorial:

http://www.sitepoint.com/javascript-shared-web-workers-html5/

Jeffrey Sweeney
  • 5,986
  • 5
  • 24
  • 32