• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Open url in a default browser

 
Vaishali soneta
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 50289
80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Javascript is usually discussed elsewhere. Moving.
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Cross Posted here: http://www.coderanch.com/t/436205/JSP/java/url-open-default-browser-client

[edit - removed comment]
 
Vaishali soneta
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic