0

I have a window which uses javascript to open another child window, in the standard window.open("http://foobar","name") manner. If I open again with the same name, it reuses the window. This is great and exactly what I want.

However, if the original window is closed, I would like to be able to reopen it and have its window.open go to the previously opened child window. Unfortunately, because it is a new parent window it will open another child window (which it will happily and correctly reuse).

Does anybody here know of a way to get hold of that previous child window so I can avoid making more windows than necessary?

Behind the scenes, the driver of this question is this: I have a java program which will periodically open different websites and I do not want to force a plethora of tabs or windows. Command-line options do not let you reuse windows or declare targets; javascript lets you declare a target. I figured I would write a small javascript page which opened a page in a specifically-named window and then close itself. Anytime you want to see a new page, hit that page passing in your new page.... Much to my dismay, though, targets seem specific to the window which creates them.

So if you have ideas which are relevant to my actual problem I'm interested too.

Robert
  • 164
  • 1
  • 12
  • It occurred to me that you might be interested in embedding a browser in your application. Here's a question on the topic: http://stackoverflow.com/questions/48249/is-there-a-way-to-embed-a-browser-in-java – mqsoh Nov 04 '11 at 21:53
  • @mqsoh this is javascript, not java, that link is not useful. – Marshall Brekka Nov 04 '11 at 22:05
  • I don't think this is possible. – Marshall Brekka Nov 04 '11 at 22:10
  • @Marshall Brekka In the fourth paragraph, Robert explains that a Java program is launching the browser. – mqsoh Nov 05 '11 at 03:07
  • @mqsoh, Marshall Brekka - You're both right. My original question is about using javascript, but it was driven by a need which can be fulfilled by embedding a browser in the application. This is why I tried to give more context to the question: in this case the answer which doesn't directly address my question is better. I will examine the embedded browser option for a bit, because as far as I can tell you can't do what I want in javascript... especially in a cross-browser manner. – Robert Nov 07 '11 at 15:25

1 Answers1

0

Embedding a browser took less time than trying various ways of controlling browsers.

Robert
  • 164
  • 1
  • 12