javascript to launch only ONE window for a Java applet with a given URL

自作多情 提交于 2019-12-24 08:46:33

问题


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: 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).


回答1:


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" )


来源:https://stackoverflow.com/questions/2301070/javascript-to-launch-only-one-window-for-a-java-applet-with-a-given-url

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!