One window inspecting and controlling elements in another

Hi folks.

Is it possible to have a javascript read elements from one browser tab from another? What I want to do is have a simple script that refreshes a page that I don’t host every second or so and if the text on it changes from a preset string then to stop refreshing. So I have one tab open running the JS that I host which is pressing refresh repeatedly on the other tab and if that changes then it stops refreshing.

I’ve tried to think of a way to do this server-side (PHP) but couldn’t think of one. I could make a script that reads the remote page repeatedly and if it changes then loads it, but to load it the remote page would refresh and then would probably lose the string I am after.

Any help much appreciated! Even if just to say “nah, not possible” or something about XSS that I don’t really understand…!

You could take a look at greasemonkey to create a userscript that does this for you.
The greasemonkey wiki is a good source to get you started on writing your own script :slight_smile:

Note that greasemonkey is for firefox, but there similar methods available for Opera, Chrome and Safari. And also for IE7Pro (not for IE itself).
Google for “greasemonkey” and the name of your browser to find out more :slight_smile:

That’s not what I wanted to hear, but thanks very much for your help.

JavaScript in one tab or window can only access content in another tab or window if:

  1. JavaScript on one of the pages opened the other page and
  2. Both pages come from the same domain.

If either of those conditions is not met then no access is possible.

JavaScript in one tab or window can only access content in another tab or window if:

  1. JavaScript on one of the pages opened the other page and
  2. Both pages come from the same domain.

If either of those conditions is not met then no access is possible.