Skip to main content

revBrowserExecuteScript

Type​

function

Summary​

Executes a string as web script in the context of the specified browser object.

Syntax​

revBrowserExecuteScript(<instanceId>, <script>)

Description​

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

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 (;).

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.

Parameters​

NameTypeDescription

instanceId

The instanceId is the integer identifier of a browser object

script

string

A string containing the web script to execute.

Examples​

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

Value​

NameTypeDescription

the result

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" :.

function: revBrowserOpen, revBrowserCallScript

glossary: function

Compatibility and Support​

Introduced

LiveCode 3.5

OS

mac

windows

Platforms

desktop

Thank you for your feedback!

Was this page helpful?