[Gambas-user] Simplest way to open a URL in a browser

Ian Roper ian.roper at iinet.net.au
Mon Aug 19 02:22:43 CEST 2019


Gidday Bruce,

I use the external program xdg to open any document that the system can 
recognize.

xdg is on 'most' systems by default and will open any document including 
pdf, odt,xml, csv,...

For a physical document , you need to pass the full path ending with the 
document name.

for a URL (web site) to be opened in the default browser, just pass it 
the full (use a http/https header) url and it will open



https://www.google.com will work fine

www.google.com is assumed to be a file and will fail.


Public Sub URLLabel1_Click()

   OpenDocument(URLLabel1.link)

End

Public Sub OpenDocument(Inpath As String)

   Exec ["xdg-open", InPath]

End


Cheers,

Ian.


On 18/8/19 6:30 pm, Bruce wrote:
> (Probably anonther dumb one)
>
> Let's say I have a URL displayed in a URLLabel control. What is the 
> simplest way to implement open that URL in the user's preferred web 
> browser? Say with a single click.
>
> Only a few requirements:
> * desktop independent (I don't know whether they have a "default 
> browser" or whatever
> * open the browser in a new window (independent of the desktop)
> * independent of the GUI involved in the current gambas project (???)
> * get a fairly clear indication of anything that (may or does) go wrong.
>
> Not too hard is it? So how come I can't do it? ;-( (Age may be a factor).
>
> tia
> bruce
>
> ----[ Gambas mailing-list is hosted by https://www.hostsharing.net ]----
>


More information about the User mailing list