File: openBrowser.System.Rd

package info (click to toggle)
r-cran-r.utils 2.13.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,864 kB
  • sloc: sh: 18; makefile: 6
file content (85 lines) | stat: -rw-r--r-- 2,518 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Do not modify this file since it was automatically generated from:
% 
%  System.R
% 
% by the Rdoc compiler part of the R.oo package.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\name{System$openBrowser}
\alias{System$openBrowser}
\alias{openBrowser.System}
\alias{System.openBrowser}
\alias{openBrowser,System-method}

\title{Opens an HTML document using the OS default HTML browser}

\usage{
## Static method (use this):
## System$openBrowser(query, ...)

## Don't use the below:
\method{openBrowser}{System}(this, query, ...)
}

\arguments{
  \item{query}{The path to document to be opened by the browser.}
}

\description{
 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 \code{query} can either be a local file or a
 web page. If the \code{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
 \code{file:}. The used url will be returned as a string.

 Any suggestion how implement this on Apple system are welcome!
}

\value{
  Returns the url of the \code{query}.
}

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

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

  On a \emph{Windows} system, if \code{<browser>} is not \code{\link[base]{NULL}},
  first

    \code{shell.exec(<browser> <url>)}

  is tried. If this fails, then

    \code{shell.exec(<url>)}

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

  On \emph{Unix} systems, \code{system()} will be used to call:

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

}

\examples{\dontrun{
  System$openBrowser("https://www.r-project.org/")
}}

\author{Henrik Bengtsson}

\seealso{
  For more information see \code{\link{System}}.
}
\keyword{internal}
\keyword{methods}