Error getting tags :
error 404Error getting tags :
error 404 revBrowserExecuteScript | revDocs | RunRev
Welcome Guest (Log in)
Product Edition
Version
revBrowserExecuteScript
Basics
Expander triangle
Type
Function
Syntax

revBrowserExecuteScript(instanceId, script)

Introduced
3.5
Environment
Desktop
Platform Support
Mac OS X,Windows
Security
Network
Summary
Executes a string as web script in the context of the specified browser object.
Examples

get revBrowserExecuteScript(sBrowserId, "alert('This is a debugging message');"
get revBrowserExecuteScript(sBrowserId, the text of field "JavaScript" of me)

Additional Comments
Expander triangle

Use the revBrowserExecuteScript function to modify the current page being displayed in a browser object, or to retrieve information about it.

Parameters

The instanceId is the integer identifier of a browser object

The script is a string containing the web script to execute.

Comments

The revBrowserExecuteScript function currently executes JScript on Windows and JavaScript on OS X. If the specified script contains more than one line, each line must be terminated with a semi-colon (;).

The return value of the function is the value of the "result" global variable in the script environment. Any values to be returned from the script should be placed into this variable. For example the following line of code produces the result "2":

put revBrowserExecuteScript(sBrowserId, "result = 1 + 1;")

If there is an existing JavaScript function you wish to call, its better to use the revBrowserCallScript function instead. This will be faster than executing arbitrary code and also allows parameters to be passed.

If the script fails to execute, an "error in script" exception will be thrown.

Note: For general information on using the browser library, please see the notes in the revBrowserOpen function reference.

User Comments
Expander triangle
User thumbnail
Oliver Kenyon
StarStarStarStarStar
Feb 16, 2009
Any JavaScript executed by the revBrowserExecuteScript and revBrowserCallScript functions will run as though in the environment of the currently loaded web page. This means that it is subject to the behavior of the particular browser in use (Internet Explorer on Windows and Safari on OS X). A particular example of this is that the document.write() method may appear not to work on OS X due to a Safari bug (https://bugs.webkit.org/show_bug.cgi?id=8961). This issue can be worked around by ensuring the text being written contains at least one html tag.