Skip to main content

Open a URL in foreground (app.open_url)

Declaration

ok = app.open_url(URL)

Parameters

Returns

  • ok
    Boolean. Whether the URL was opened successfully.

Notes

  • Open a URL in the foreground. Can open URL Scheme (see URL Scheme usage).
  • For some URLs, this API may not give the desired behavior. In a jailbreak environment you can try the uiopen shell command instead:
local function sh_escape(path) -- XXTouch original function; allowed for commercial use with credit
path = string.gsub(path, "([ \\()<>\'\"`#&*;?~$|])", "\\%1")
return path
end
os.execute('uiopen '..sh_escape('https://www.google.com'))
os.execute('uiopen '..sh_escape('prefs:root=SAFARI&path=CLEAR_HISTORY_AND_DATA'))

Example

app.open_url("https://www.google.com") -- open Google in Safari (may not be accessible)
--
app.open_url("prefs:root=SAFARI&path=CLEAR_HISTORY_AND_DATA") -- Settings -> Safari -> Clear History and Website Data