# Controlling another browser window

**URL:** <https://www.ruby-forum.com/t/controlling-another-browser-window/181124>\
**Category:** Ruby\
**Created:** [January 5, 2010, 10:54pm UTC](https://www.ruby-forum.com/t/controlling-another-browser-window/181124 "2010-01-05T22:54:54Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dezrtdude](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/f4b2a3/32.png) [@dezrtdude](https://www.ruby-forum.com/u/dezrtdude)\
**Post date:** [January 5, 2010, 10:54pm UTC](https://www.ruby-forum.com/t/controlling-another-browser-window/181124/1 "2010-01-05T22:54:54Z")

</div>

I have a set of static html files with their own links (essentially a  
book). What I want to do is have another browser window that’s a sort  
of companion tied to whichever window is viewing the book files, which  
will update when a link in the book window is followed and also control  
whether the book page can change. However, I’m not allowed to modify  
the static files in any way.

What I do have is the right to serve the pages (eventually I might want  
to do this via a proxy or similar method, but for now assume I have the  
files locally). I could have a setup page that launches both windows  
using Javascript and keeps a reference to the ‘parent’ that has the  
book. Is there a way to pass that to Ruby code and maintain it for as  
long as needed?

As an example of what I’m trying to do : If my book is, say  
Shakespeare’s Julius Caesar, the second window might contain vocabulary  
words, notes, errata, study questions, etc. Each time a page is turned  
by clicking a link in the book, the second window would need to update;  
if the user is in the middle of answering a question, then the book page  
should not be allowed to change.

(I know there’s probably no way around going _back_ in the browser;  
that’s acceptable. This needs to be cross-platform, so shouldn’t rely  
on controlling the browser directly.)

---

<div class="post-metadata">

**Author:** ![dezrtdude](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/f4b2a3/32.png) [@dezrtdude](https://www.ruby-forum.com/u/dezrtdude)\
**Post date:** [January 5, 2010, 11:55pm UTC](https://www.ruby-forum.com/t/controlling-another-browser-window/181124/2 "2010-01-05T23:55:19Z")

</div>

Something pretty close is described in this technique:  
[http://openid-demo.appspot.com/](http://openid-demo.appspot.com/)

I have used it to accept OpenID’s on a page.  
(Which is backed by Ruby code).

So, possible each page would respond via callbacks.  
Javascipt ‘switch’ statement therein.

Close, possibly a gotcha in there somewhere.

MarkT

---

<div class="post-metadata">

**Author:** ![dezrtdude](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/f4b2a3/32.png) [@dezrtdude](https://www.ruby-forum.com/u/dezrtdude)\
**Post date:** [January 7, 2010, 5:30am UTC](https://www.ruby-forum.com/t/controlling-another-browser-window/181124/3 "2010-01-07T05:30:21Z")

</div>

Now that I think about it, maybe I can do something like this:

Open both the book page and the companion page separately. Then have  
the companion page (using AJAX?) wait for updates to the book page. The  
server can notify the companion page of what to do whenever the book  
page changes.

That should be possible, right? My Javascript/AJAX knowledge is pretty  
weak.
