browsers
This module implements a simple proc for opening URLs with the user's default browser.
Unstable API.
Imports
Consts
osOpenCmd = "xdg-open"
- Alias for the operating system specific "open" command,
"open"
on OSX, MacOS and Windows,"xdg-open"
on Linux, BSD, etc. Source Edit
Procs
proc openDefaultBrowser(url: string) {...}{.raises: [ValueError, OSError, Exception], tags: [ ExecIOEffect, ReadEnvEffect, RootEffect].}
-
Opens
url
with the user's default browser. This does not block. The URL must not be empty string, to open on a blank page seeopenDefaultBrowser()
.Under Windows,
ShellExecute
is used. Under Mac OS X theopen
command is used. Under Unix, it is checked ifxdg-open
exists and used if it does. Otherwise the environment variableBROWSER
is used to determine the default browser to use.This proc doesn't raise an exception on error, beware.
block: openDefaultBrowser("https://nim-lang.org")
Source Edit proc openDefaultBrowser() {...}{.raises: [ValueError, OSError, Exception], tags: [ExecIOEffect, ReadEnvEffect, RootEffect].}
-
Opens the user's default browser without any
url
(blank page). This does not block. Implements IETF RFC-6694 Section 3, "about:blank" must be reserved for a blank page.Under Windows,
ShellExecute
is used. Under Mac OS X theopen
command is used. Under Unix, it is checked ifxdg-open
exists and used if it does. Otherwise the environment variableBROWSER
is used to determine the default browser to use.This proc doesn't raise an exception on error, beware.
See also:
block: openDefaultBrowser()
Source Edit
© 2006–2021 Andreas Rumpf
Licensed under the MIT License.
https://nim-lang.org/docs/browsers.html