HTMLViewer.ExecuteJavaScript

From Xojo Documentation

Method

HTMLViewer.ExecuteJavaScript(js As String)

New in 2011r4

Supported for all project types and targets.

Executes the passed JavaScript in the context of the currently loaded page. Attempting to execute JavaScript before the page finishes loading (or if no page is loaded) is undefined and is unlikely to work.

Notes

In order to call JavaScript on Windows using the Native renderer, a document must already be loaded into the HTMLViewer. If no document is loaded, an HTMLViewerException is raised.

Example

This code will populate the search field on the wikipedia page (assuming it was previously loaded):

Var jsSrc As String
jsSrc = "document.forms[0].elements['search'].value=""xojo"";"
HTMLViewer1.ExecuteJavaScript(jsSrc)

This code writes text to the HTML document:

Var this As String
this = "document.writeln(""hello"");"
HTMLViewer1.ExecuteJavaScript(this)