Calls a function on the opened web page given its name and arguments.
JavaScript counterpart is jrc.callFunction(name, arguments, assignTo, package)
,
where the package
argument allow to call function from some other
package. The result, however, will be anyway assigned to a variable in the
environment set by setEnvironment
.
For security reasons, if function or variable to which its returned value
should be assigned are not in the lists of allowed functions and variables,
manual authorization of the call form JavaScript in the R session will be
required. For more details check authorize
.
callFunction(name, arguments = NULL, assignTo = NULL, thisArg = NULL,
...)
Name of the function. If the function is a method of some object
its name must contain the full chain of calls (e.g. myArray.sort
or
Math.rand
).
List of arguments for the function. Note that in JavaScript arguments must be given in a fixed order, naming is not necessary and will be ignored.
Name of a variable to which will be assigned the returned value of the called function. If variable with this name doesn't exist, it will be added to the currently active environment.
JavaScript functions (methods) can belong to some object, which
is referred as this
inside the function (e.g. in
someObject.myFunction()
function myFunction
is a method of someObject
).
thisArg
specified object that will be passed as this
to the function. If NULL
then the function will be applied to the global object.
further arguments passed to sendData
that is used to send
arguments
to the web server.
# NOT RUN {
openPage()
callFunction("alert", "Some alertText")
callFunction("Math.random", assignTo = "randomNumber")
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab