aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes Open url in a default browser Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Open url in a default browser" Watch "Open url in a default browser" New topic
Author

Open url in a default browser

Vaishali soneta
Greenhorn

Joined: Mar 16, 2009
Posts: 5
I want the url to open in the default browser of the client. Can anyone help me how to achieve this.. I want to do this on Client side... Can we do this on Javascript.. Please suggest. I am just stuck in here...
I am able to get the alert with the url but just not able to open a new window in default browser...
<script type="text/javascript"><![CDATA[
function test(tbxss){
alert('testing' + tbxss);
java.lang.Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + tbxss);
}



]]></script>
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38353
    
  23
Javascript is usually discussed elsewhere. Moving.
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
You are not going to be opening a window with java markup inside of JavaScript.

You probably want to use window.open("url"); or window.location.href("url");

Eric
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
Cross Posted here: http://www.coderanch.com/t/436205/JSP/java/url-open-default-browser-client

[edit - removed comment]
Vaishali soneta
Greenhorn

Joined: Mar 16, 2009
Posts: 5
I tried window.open(url) or window.location.href(url) but it works only in the firefox and not in googlechrome, adobeair and IE.. and basically it should open in a user's default browser.. So any help would be appreciated
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
It will open up in the browser the user is currently using. Why would you want to open up Firefox if the user is in chrome? Sounds funny and most people's default browser is the one they use.

Eric
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
Vaishali soneta wrote:I tried window.open(url) or window.location.href(url) but it works only in the firefox and not in googlechrome, adobeair and IE.. and basically it should open in a user's default browser.. So any help would be appreciated

So IE is your default browser. Why do you want to open it in the default browser instead of the current browser? This makes no sense and is generally very bad for user experience.

You can't do this with JS. Best what you can do is creating a Java application which makes use of Desktop#browse() and embed it as an applet or webstart app in your JSP.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Open url in a default browser