How do you open Safari?

I just want to have a button link to an external site, so that when clicked it opens up Safari and goes to the specified URL. [import]uid: 52127 topic_id: 12859 reply_id: 312859[/import]

Yep i want the exact same thing for a client i’m making an app for not sure how to do it either. [import]uid: 22223 topic_id: 12859 reply_id: 47196[/import]

[lua]local function testNetworkConnection()
local netConn = require(‘socket’).connect(‘www.apple.com’, 80)
if netConn == nil then
return false
end
netConn:close()
return true
end

local DEVICE = system.getInfo ( “environment” )
local AppURL = “http://url.of.your.choice/
if DEVICE == “simulator” then
print ( “Cannot spawn this URL in the simulator” )
else
if testNetworkConnection() then
system.openURL ( AppURL )
end
end[/lua]

though there are new event api’s that might be better than this method of testing for a network connection, though this one does work.
[import]uid: 19626 topic_id: 12859 reply_id: 47198[/import]

http://developer.anscamobile.com/reference/index/systemopenurl

@robmiracle, why do you need to do all those checks for network connection or simulator environment? I just used a single line (system.openURL(“http://www.website.com”) and it works fine even in the simulator. Is this just used to make your app more user friendly so you can return a “not connected” type message? [import]uid: 31262 topic_id: 12859 reply_id: 47203[/import]

Because it was in the code I stole… er. borrowed from.

Its basically good practice, as you said, so you can let the user know whats going on.

[import]uid: 19626 topic_id: 12859 reply_id: 47211[/import]

thanks, this works. [import]uid: 52127 topic_id: 12859 reply_id: 47222[/import]