开发者

How to open new browser window on a client, rather than a server

开发者 https://www.devze.com 2023-02-03 03:30 出处:网络
This question has been asked before, but does not have an answer yet: I\'m trying to use \"java.awt.Desktop.getDesktop().browse(java.net.URI.create(myURL));\" in a client/server application.

This question has been asked before, but does not have an answer yet:

I'm trying to use "java.awt.Desktop.getDesktop().browse(java.net.URI.create(myURL));" in a client/server application.

I want the default browser to open on the client side when the client clicks on a button. What happens is that the browser opens on 开发者_开发技巧the server. How can I fix it?

Any help would be appreciated.


Use the JavaScript window.open method in the generated source, e.g.

<script type='text/javascript'>
  var windowObjectReference;
  var strWindowFeatures = "menubar=yes,location=yes,resizable=yes,scrollbars=yes,status=yes";
  windowObjectReference = window.open("http://www.example.com/", "WindowName", strWindowFeatures);
</script>


Java doesn't run at webbrowser. It runs at webserver. It's HTML/CSS/JS which runs at webbrowser. You need to solve this by HTML/CSS/JS. CSS is incapable for this. JS can do this with window.open, but that's overcomplicated if you can just use HTML target="_blank" in a link/form.

E.g.

<a href="http://google.com" target="_blank">Click to view Google in a new window</a>

or

<form action="http://google.com" target="_blank">
    <input type="submit" value="Press to view Google in a new window" />
</form>

This will open the target in a new window/tab.

0

精彩评论

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