javascript 为具有给定 URL 的 Java 小程序仅启动一个窗口 [英] javascript to launch only ONE window for a Java applet with a given URL

查看:15
本文介绍了javascript 为具有给定 URL 的 Java 小程序仅启动一个窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于给定的 URL,我需要一个 javascript 解决方案来仅启动一个窗口,其中包含一个 Java Applet.我在 Stack Overflow 上找到了一个解决方案 -此处:JavaScript window.open only if window不存在

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

但它似乎不起作用..我明白了错误:launchApplication.winrefs 未定义行:29

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

我似乎无法将代码张贴在这个小盒子中并让它看起来就在下面,所以代码(我的工作代码,加上上面的解决方案)在这里:http://pastie.org/833879

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

错误在哪里?

据我所知,如果调用窗口关闭,哈希或数组或我用来存储对以这种方式打开的窗口的调用引用的任何东西都将丢失.

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.

即使关闭并重新打开调用窗口,有没有办法使这项工作正常进行?基本上询问浏览器:您是否打开了一个带有以下 URL 的窗口?"如果是这样,对那个窗口的引用是什么?"(所以我可以提出来).

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

推荐答案

第一个问题 [已解决]

我看到您在一处使用了 winRefs,然后是 winrefs.可能只是您需要在第二个大写 R 的情况下.您的代码中似乎出现了几次小写版本,即使在第 29 行之后也是如此.请务必在再次测试之前更新所有版本.

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.

我刚刚注意到这一行:

if ( typeof launchApplication.winRefs == undefined )

如果 .winRefs 不存在,则不会返回 true.当然,如果未找到该属性,我们希望它返回 true,因此我们必须将 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" )

这篇关于javascript 为具有给定 URL 的 Java 小程序仅启动一个窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆