Is there a way to launch the default browser with configured starting URL?

Subject says it all. I know I can open specified URL using System.GotoURL() and that works fine.

I’d also like to have the option to have XoJo launch system default browser and go to the configured startup URL. I’ve tried just feeding it “http://” and of course that brings up the default browser with an error that it can’t connect to the server. If I just do System.GotoURL("") the browser doesn’t open at all, which doesn’t surprise me.

I don’t see other options in my searching. Suggestions would be appreciated. :slight_smile:

This seems to work on everything but Safari on Mac:


I looked into this and can’t come up with a universal way via GotoURL. The reason is that two things have to happen:

  1. The OS has to choose the default URL scheme handler, so for your default browser, this has to be http://
  2. The browser has to be able to execute the passed URL

It seems most browsers will take http:// and just go to the default, while Safari tries to actually execute it. Safari doesn’t seem to have a browser URL scheme, so I don’t think there’s a way with GotoURL. I tried other tricks like data URLs and redirects without success (these kinds of things are blocked for security reasons, but you also run into #1 above unless it’s an HTTP URL).

I think the only universal solution would be to look up the default browser (it’s in the registry on Windows and a plist on Mac - you can find the info by googling), and then just execute that binary.


You can always open Safari, which you are sure exists in Applications.

dim s as new shell
s.execute("Open /Applications/")

It’s also worth pointing out that browsers don’t al aus have a “default page” per se. Safari is a good example. On my machine, the first page shows tiles of my recently viewed pages and my favorites.

@Michel_Bujardet may be onto something though, you may be able to use declares (or registry lookups) to find out which app is responsible for http: calls and then just tell that app to launch.

1 Like

You could just fallback to:

System.GoToURL( "about:blank" )

It’s not the browser homepage, but it’s a starting point that doesn’t result in an error.

I don’t think this works… you need the “http://” for the system to figure out the default handler for the protocol. “about:” isn’t a protocol. See my note above…

No, “about:” is an internal URI. Try it. Open your browser and enter “about:blank” as the URL. It just loads a blank page and has been part of practically every major browser for a very long time.

Yes, it works in the browser. It does not work from an external application because the system has to first resolve the app to handle the protocol. I just tried this again on my Mac: it does’t work from GotoURL regardless of which browser is set to the default. Did you get it to work?

But note that “about:blank” is the only thing that works within Safari; it doesn’t support any of the other “about:” or browser-specific (e.g. “chrome:”) URL schemes.

Also, the OP was looking for the default page, which may not be set, in which case you get the equivalent of “about:blank”

I see what you’re saying. In those cases – at least on my Mac for Firefox, Opera, and Chrome – using this does open about:blank:

System.GotoURL( "http://about:blank" )

On Safari it opens a page with an error message.

If you want to launch the default browser home page, there’s no URI for that of which I’m aware. As far as I know, you’d have to determine the default browser based on target OS and launch it without passing a URL as you said above.

Yup, I suspect that was the OP’s experience. I experimented with this on Mac and Windows and what you have would work everywhere except Safari. But, same is true for System.GotoURL("http://") which does what the OP wants (default browser+default page), again with everything but Safari. This appears to be equivalent to System.GotoURL("http://about:newtab")

As I and Michel indicated, the only universal way is to get the default browser on the system you are on (registry or plist lookup) and then execute the associated binary which should open to the default page on launch, of course. Or, just check if you’re on Mac, then look for the default, and if it is Safari, launch it, otherwise System.GotoURL("http://")

I feel like there was some code on the old forums that would get the default browser for at least macOS and Windows, but I do question why OP wants to open the browser to the user’s home page. That could be confusing to users. I feel like going to a pre-configured URL hosted on their own domain or an HTML file that is distributed with their software would be better. This page should probably contain some instruction or, at least, an explanation.

It is here. In fact, I can’t imagine using anything else as a homepage.

Several good suggestions for me to look into. Obviously, my goal would be to have it consistent between the Desktop OSs along with keeping the code straight forward. I’d thought about sending it to google. I do like Anthony’s suggestion of sending it to a locally hosted HTML page. I did think about that originally, but was trying to see if there was a way to launch the default browser using its default start page without a bunch of fuss.

I’ll probably just go with the locally hosted page which is quick, easy and gives the ability to provide info.

Thanks All!

1 Like

Please don’t. I know some users, including me, who make their best to avoid google.


Any reason to avoid a file resource page?

Like: System.GotoURL(“file:///Resources/SomePages/opening.html”)

I hear that. Sending to Google or any site think of might be irritating to some users. That’s why I thought to open the default browser to the default start page.

1 Like

Not at all. That’s what I’m leaning towards.