From Xojo Documentation

You are currently browsing the old Xojo documentation site. Please visit the new Xojo documentation site!

DesktopHTMLViewer.ExecuteJavaScript(js As String)

New in 2021r3

Supported for all project types and targets.

Asynchronously 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.

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.

Sample Code

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"";"

This code writes text to the HTML document:

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

See Also

ExecuteJavaScriptSync method.