Difference between revisions of "WebControl.ExecuteJavaScript"

From Xojo Documentation

(Example)
m
 
Line 8: Line 8:
 
}}
 
}}
 
{{Description | text=Executes the JavaScript passed. The JavaScript passed can call a JavaScript function in a WebPageSource control. }}
 
{{Description | text=Executes the JavaScript passed. The JavaScript passed can call a JavaScript function in a WebPageSource control. }}
 
  
 
==Notes==
 
==Notes==
 
ExecuteJavaScript is also available as a [[ExecuteJavaScript | global method]]. If called as a global method, it tries to determine which control in which it is supposed to run. In general, calling the JavaScript from inside the intended control is preferable.
 
ExecuteJavaScript is also available as a [[ExecuteJavaScript | global method]]. If called as a global method, it tries to determine which control in which it is supposed to run. In general, calling the JavaScript from inside the intended control is preferable.
 
  
 
== Example ==
 
== Example ==
Line 20: Line 18:
 
Me.ExecuteJavaScript("alert('Hello!');")
 
Me.ExecuteJavaScript("alert('Hello!');")
 
</rbcode>
 
</rbcode>
 
  
 
This code will select the text in a WebTextField (or WebTextArea):
 
This code will select the text in a WebTextField (or WebTextArea):

Latest revision as of 15:55, 11 August 2017

Method

WebControl.ExecuteJavaScript(JavaScript As String)

New in 2010r4

Supported for all project types and targets.

Executes the JavaScript passed. The JavaScript passed can call a JavaScript function in a WebPageSource control.

Notes

ExecuteJavaScript is also available as a global method. If called as a global method, it tries to determine which control in which it is supposed to run. In general, calling the JavaScript from inside the intended control is preferable.

Example

This code in the Action event of a Button displays an alert using JavaScript:

Me.ExecuteJavaScript("alert('Hello!');")

This code will select the text in a WebTextField (or WebTextArea):

WebTextField1.ExecuteJavascript("document.getElementById('" + _
WebTextField1.ControlID + "_inner').select();")

See Also

ExecuteJavaScript, JavaScript