Reputation: 1
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.
Upvotes: 0
Views: 4266
Reputation: 1108642
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.
Upvotes: 0
Reputation: 23316
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>
Upvotes: 1