Table of Contents
WebViewExtensions.EvalScriptAsync Method (WebView, String, String)

Asynchronously Execute JavaScript code in a frame and returns the result value.

Syntax
 public static Task<T> EvalScriptAsync<TResult>(
   WebView webView,
   string script,
   string frameName = null
);

Type Parameters

TResult
The type of the result value.

Parameters

webView
The WebView object.
script
The JavaScript code to be executed.
frameName
The name of the frame in which the code to be executed. Pass null to execute the code in the main frame.

Return Value

A task that represents the asynchronous operation. The Value of its Result property contains the result value of the JavaScript code.

Remarks

The following code demonstrates how to get the current document Url:

string s = await webView.EvalScriptAsync<string>("window.location.href");

See Also