简体   繁体   English

Java Webstart…与不同平台上的浏览器的交互

[英]Java Webstart…interaction with browsers on different platforms

This post is similar to this post , but not exactly, so I'm asking this question. 这篇文章是类似于这个帖子 ,但不完全,所以我提出这个问题。

How does one go about, From a Java WebStart app: 从Java WebStart应用程序如何进行:

  • launch a new browser window with a target URL? 启动带有目标URL的新浏览器窗口?

  • bring an existing browser window into focus with a target URL? 使用目标URL使现有的浏览器窗口聚焦?

Is the solution OS/platform independent? 解决方案操作系统/平台是否独立? Does it matter which browser you're talking to? 您与哪个浏览器对话是否重要?

launch a new browser window with a target URL 启动带有目标URL的新浏览器窗口

Use the BasicService 's showDocument method. 使用BasicServiceshowDocument方法。

import javax.jnlp.*;

// Other stuff here

   try {
       // Lookup the javax.jnlp.BasicService object
       BasicService bs = (BasicService)ServiceManager.lookup("javax.jnlp.BasicService");
       // Invoke the showDocument method
       bs.showDocument(url); // returns a boolean
   } catch(UnavailableServiceException ue) {
       // Service is not supported
   } 

bring an existing browser window into focus with a target URL? 使用目标URL使现有的浏览器窗口聚焦?

That, unfortunately, I don't know. 不幸的是,我不知道。

See @R. 参见@R。 Bemrose answer, with the caveat that it is not clear whether showDocument will or will not always open a new browser window. Bemrose的回答是警告,目前尚不清楚showDocument是否会或永远不会打开新的浏览器窗口。

Is the solution OS/platform independent? 解决方案操作系统/平台是否独立? Does it matter which browser you're talking to? 您与哪个浏览器对话是否重要?

The solution is notionally OS/platform/browser independent, but the behavior may be OS/platform/browser specific. 从理论上讲,该解决方案与OS /平台/浏览器无关,但是该行为可能是OS /平台/浏览器特定的。 As you should expect. 如您所料。 We are talking about interactions with components that are not implemented by Sun and that don't conform to any relevant API standards. 我们正在谈论与未由Sun实施且不符合任何相关API标准的组件的交互。

Another issue is that your code may want to open a new browser window, or load into an existing one, but the ultimate decision should rest with the user via his/her browser preferences. 另一个问题是,你的代码可能打开一个新的浏览器窗口,或者加载到一个现有的,但最终的决定应该通过他/她的浏览器首选用户休息。 We are talking about (potentially) unwanted popups here ... the kind of things that many users find intensely annoying. 我们在这里谈论(潜在地)不需要的弹出窗口……许多用户感到非常讨厌的事情。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM