views:

59

answers:

1

I need a javascript solution to launch only one window, with a Java Applet in it, for a given URL. I found a solution posted here on Stack Overflow - here: http://stackoverflow.com/questions/528671/javascript-window-open-only-if-the-window-does-not-already-exist

But it doesn't seem to work .. I get Error: launchApplication.winrefs is undefined Line: 29

I can't seem to post the code in this little box and make it look right below, so the code (my working code, plus the solution from above) is here: http://pastie.org/833879

Where is the error?

As I understand it, the hash or array or whatever I use to store the called references to the windows opened this way will be lost if the calling window is closed.

Is there a way to make this work even if the calling window is closed and reopened? To basically ask the browser: "Do you have a window open with the following URL?" and if so, "What is the reference to that window?" (so I can raise it).

A: 

First Problem [Resolved]

I see that you're using winRefs in one spot, and later winrefs. It may just be the case that you need to uppercase the R on the second. It appears that you've got the lowercase version in your code a few times, even after line 29. Be sure to update all of them before testing again.

Second Problem

I just noticed that this line:

if ( typeof launchApplication.winRefs == undefined )

Will not return true if .winRefs is absent. Of course we want it to return true if the property is not found so we have to wrap undefined in quotes to get this working the way we want:

if ( typeof launchApplication.winRefs == "undefined" )
Jonathan Sampson
Thank you. I hadn't caught that. fixed it, now all the winrefs are "winRefs"... but still giving the same error.
Jonathan Dugan
@Jonathan: Checkout my second updated.
Jonathan Sampson