FolderItem.Launch - exists no more

I have a cross-platform app that will run on Mac, Windoze, and Linux. I need to trigger the default web browser to open a URL that I pass to it.

I’ve searched around and saw that some people were using FolderItem.Launch but that seems to be long gone in 2024 versions.

So what is the best way to do this? I don’t care if the user is using Chrome, Safari, IExplorer, Opera or whatever. I just need to trigger it to open.

Try: FolderItem.Open

I think this will be helpful

WebFile.Open

https://documentation.xojo.com/api/web/webfile.html#webfile-open

I tried:

var f as FolderItem = new FolderItem
f.Open( “Google Maps” )

and it just opens a finder on MacOS.

WebFile.Open seems to me to be trying to pull the web into a local web browser within the app. I am wanting to simple tell the users default web browser to open the url I specify.

Have you tried System.GoToURL()?

1 Like

Thanks Scott! That seems to work on MacOS at least. Will try on the other OS when I can.

1 Like

it’s not chatgpt.

People do not like links to the documentation, but sorry:

https://documentation.xojo.com/api/files/folderitem.html#folderitem-open

Hi Emile, the “Google Maps” was actually an https link that somehow the forum converted to the name “Google Maps”.

I do read the doc, I was thrown off by looking at older forum posts showing FolderItem.Launch.

The only correct post that you need in this thread is Scott’s.

4 Likes

Don’t take your head, it works everywhere !
gotoURL ( url as string )

J Luc, This does indeed seem to work everywhere!

In that case, could you please be so kind as to mark the post as answered?

It’ll help the next person that has the same question. Thank you.

1 Like

Yep… sorry.

1 Like

I was dealing with the same issue 2 days ago. The problem with System.GoToURL() is that it always escapes the URL string whether u want to or not. So I have a URL from Microsoft SharePoint that looks something like this:

https://uofc-my.sharepoint.com/:p:/r/personal/stuff removed_layouts/15/Doc.aspx?sourcedoc=%7B932498D4-E1CA-47CD-70F467CC0FFA%7D&file=K114%205xFAD%20brain.pptx&action=edit

If I paste this directly into a browser it works as it should. If I send this to System.GoToURL() it fails because what the browser receives is an escaped version where all the original ‘%’ chars are replaced with their escaped equivalents: %25, and so on, mangling the original URL.

So I had to use a shell:
sh.Execute(“open ‘https://myURLstring’”)

Just a caution because if you rely on System.GoToURL() it will work with many but not all URLs. It would be nice if this call had a dontEscape option.

Which is a fine solution.

However, beware that this might open one up to injection-style attacks if any of the data in the URL comes from an un-trusted party.

As a hypothetical example, if the sourcedoc= parameter came from the web, a hacker could do this:

sourcedoc="test.doc & format /y /Q C:"

and you would have a Bad Day.

above my pay grade but i’ll take ur word for it! But if u can’t trust the original URL string i imagine that System.GoToURL() would suffer from the same issue?

No, System.GoToURL encodes the URL and, presumably, otherwise make it safe, which is what you’re having trouble with.