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.
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:
The OS has to choose the default URL scheme handler, so for your default browser, this has to be http://
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.
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”
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.
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.