开发者

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:

  • launch a new browser window with a target URL?

  • bring an existing browser window into focus with a target URL?

开发者_StackOverflow中文版

Is the solution OS/platform independent? Does it matter which browser you're talking to?


See @R. Bemrose answer, with the caveat that it is not clear whether showDocument will or will not always open a new browser window.

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

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.


launch a new browser window with a target URL

Use the BasicService's showDocument method.

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?

That, unfortunately, I don't know.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜