System$openBrowser

0th

Percentile

Opens an HTML document using the OS default HTML browser

Opens an HTML document using the OS default HTML browser. Note that this call is dependent on the operating system (currently only Windows and Unix are supported). The document given by query can either be a local file or a web page. If the query was given as non-url string, i.e. as a standard file pathname, the method will automatically check if the file exists and conform the query to a correct url starting with file:. The used url will be returned as a string.

Any suggestion how implement this on Apple system are welcome!

Keywords
methods, internal
Usage
## Static method (use this):
## System$openBrowser(query, ...)

## Don't use the below: # S3 method for System openBrowser(this, query, ...)

Arguments
query

The path to document to be opened by the browser.

Details

It is hard to create a good cross-platform openBrowser() method, but here is one try.

In the following text <browser> is the value returned by getOption("browser") and <url> is the URL conformed query, which starts with either file: or http:.

On a Windows system, if <browser> is not NULL, first

shell.exec(<browser> <url>)

is tried. If this fails, then

shell.exec(<url>)

is tried. Using this latter approach will not guarantee that an HTML browser will open the url, e.g. depending on the Windows file associations, a *.txt file might be opened by NotePad. However, it will most likely open something. If <browser> contains spaces, make sure it is quoted.

On Unix systems, system() will be used to call:

<browser> -remote "openURL(<url>)" 2> /dev/null || <browser> <url> &

Value

Returns the url of the query.

See Also

For more information see System.

Aliases
  • System$openBrowser
  • openBrowser.System
  • System.openBrowser
  • openBrowser,System-method
Examples
# NOT RUN {
  System$openBrowser("http://www.r-project.org/")
# }
Documentation reproduced from package R.utils, version 2.8.0, License: LGPL (>= 2.1)

Community examples

Looks like there are no examples yet.