WebView.ExecuteScriptAsync
method · WebView · cAlgo.API
Executes JavaScript code from the javaScript parameter in the current top level document rendered in the WebView. You can only use this method after control is fully loaded and navigation is completed.
Environment behaviour
CLI — not supported. Accepted without error but never displayed, so control events such as Click are never raised.
Cloud — not supported. Accepted without error but never displayed, so control events such as Click are never raised.
Overloads
| Signature | Description |
|---|---|
ExecuteScriptAsync(string javaScript) | Executes JavaScript code from the javaScript parameter in the current top level document rendered in the WebView. You can only use this method after control is fully loaded and navigation is completed. |
ExecuteScriptAsync(string javaScript, Action<ExecuteScriptResult> callback) | Executes asynchronously JavaScript code from the javaScript parameter in the current top level document rendered in the WebView. You can only use this method after control is fully loaded and navigation is completed. |
ExecuteScriptAsync(string javaScript)
Executes JavaScript code from the javaScript parameter in the current top level document rendered in the WebView. You can only use this method after control is fully loaded and navigation is completed.
public void ExecuteScriptAsync(string javaScript)
webView.ExecuteScriptAsync(javaScript: str) -> None
Parameters
| Name | C# type | Python type | Description |
|---|---|---|---|
javaScript | string | str | JavaScript code |
Examples
var webView = new WebView { Width = 300, Height = 100 };
webView.NavigateToStringAsync("<html><body id='price'></body></html>");
webView.NavigationCompleted += args => webView.ExecuteScriptAsync("document.getElementById('price').innerText = '" + Symbol.Bid + "'");
Chart.AddControl(webView);
webView = WebView()
webView.Width = 300
webView.Height = 100
webView.NavigateToStringAsync("<html><body id='price'></body></html>")
webView.NavigationCompleted += lambda args: webView.ExecuteScriptAsync(f"document.getElementById('price').innerText = '{api.Symbol.Bid}'")
api.Chart.AddControl(webView)
ExecuteScriptAsync(string javaScript, Action<ExecuteScriptResult> callback)
Executes asynchronously JavaScript code from the javaScript parameter in the current top level document rendered in the WebView. You can only use this method after control is fully loaded and navigation is completed.
public void ExecuteScriptAsync(string javaScript, Action<ExecuteScriptResult> callback)
webView.ExecuteScriptAsync(javaScript: str, callback: Callable[[ExecuteScriptResult], None]) -> None
Parameters
| Name | C# type | Python type | Description |
|---|---|---|---|
javaScript | string | str | JavaScript code |
callback | Action<ExecuteScriptResult> | Callable[[ExecuteScriptResult], None] | The callback that will be called after execution finished |
Examples
var webView = new WebView { Width = 300, Height = 100 };
webView.NavigateToStringAsync("<html><body>Hello</body></html>");
webView.NavigationCompleted += args => webView.ExecuteScriptAsync("document.body.innerText", result => Print("Successful: {0}, JSON: {1}", result.IsSuccessful, result.Json));
Chart.AddControl(webView);
webView = WebView()
webView.Width = 300
webView.Height = 100
webView.NavigateToStringAsync("<html><body>Hello</body></html>")
webView.NavigationCompleted += lambda args: webView.ExecuteScriptAsync("document.body.innerText", lambda result: api.Print(f"Successful: {result.IsSuccessful}, JSON: {result.Json}"))
api.Chart.AddControl(webView)