Opening a Web Browser from LOVE

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Bannana97
Citizen
Posts: 77
Joined: Wed May 16, 2012 2:49 pm

Opening a Web Browser from LOVE

Post by Bannana97 »

Hey guys and girls.

I was wondering if it was possible to open a URL in the computer's default web browser from my LOVE game.
I am trying to make a Help button and I want it to open http://myurl.com/game/help.aspx.

Thanks! :awesome:
blenderer
Prole
Posts: 16
Joined: Fri Feb 12, 2010 1:19 am

Re: Opening a Web Browser from LOVE

Post by blenderer »

I was looking around Stack Overflow and found this(it might help you)

http://stackoverflow.com/questions/1116 ... -extension (Found kikito with an answer, ironically)

http://stackoverflow.com/questions/2950 ... lua-script (To find what OS lua is being hosted on)

You would have to find the OS the user is on, then execute the system-specific command to open that url with the default browser.

Use os.execute([command]) to execute the OS-specific command.
Bannana97
Citizen
Posts: 77
Joined: Wed May 16, 2012 2:49 pm

Re: Opening a Web Browser from LOVE

Post by Bannana97 »

Thanks.
Works perfect. :)
User avatar
slime
Solid Snayke
Posts: 3162
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

Re: Opening a Web Browser from LOVE

Post by slime »

love._os is a string containing either "OS X", "Windows", or "Linux" currently.
Bannana97
Citizen
Posts: 77
Joined: Wed May 16, 2012 2:49 pm

Re: Opening a Web Browser from LOVE

Post by Bannana97 »

Thanks, slime.
That will help a lot in the next month or so. :awesome:
Bannana97
Citizen
Posts: 77
Joined: Wed May 16, 2012 2:49 pm

Re: Opening a Web Browser from LOVE

Post by Bannana97 »

blenderer wrote:I was looking around Stack Overflow and found this(it might help you)

http://stackoverflow.com/questions/1116 ... -extension (Found kikito with an answer, ironically)

http://stackoverflow.com/questions/2950 ... lua-script (To find what OS lua is being hosted on)

You would have to find the OS the user is on, then execute the system-specific command to open that url with the default browser.

Use os.execute([command]) to execute the OS-specific command.
Okay, I can use os.execute to open a web page.
However, when I add GET fields (?f1=v1&f2=v2) it removes them.
Any way to stop this? I need to allow GET fields for my game to work.
Santos
Party member
Posts: 384
Joined: Sat Oct 22, 2011 7:37 am

Re: Opening a Web Browser from LOVE

Post by Santos »

On Windows, you can use a ^ to escape an &, so

Code: Select all

os.execute('start https://love2d.org/forums/posting.php?mode=reply^&f=4^&t=9930')
opens this thread! :D
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Opening a Web Browser from LOVE

Post by Robin »

Are you surrounding the address by "double quotes"?
Help us help you: attach a .love.
Bannana97
Citizen
Posts: 77
Joined: Wed May 16, 2012 2:49 pm

Re: Opening a Web Browser from LOVE

Post by Bannana97 »

Robin wrote:Are you surrounding the address by "double quotes"?
Ahhaha! I am an idiot!
Sorry, and thanks!
Bannana97
Citizen
Posts: 77
Joined: Wed May 16, 2012 2:49 pm

Re: Opening a Web Browser from LOVE

Post by Bannana97 »

Robin wrote:Are you surrounding the address by "double quotes"?
Okay, it opens up a CMD window with that URL as the title now...
is that normal? lol
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Google [Bot] and 5 guests