WebView.InvokeScriptAsync(String, IIterable<String>) Method
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Executes the specified script function from the currently loaded HTML, with specific arguments, as an asynchronous action.
public:
virtual IAsyncOperation<Platform::String ^> ^ InvokeScriptAsync(Platform::String ^ scriptName, IIterable<Platform::String ^> ^ arguments) = InvokeScriptAsync;
/// [Windows.Foundation.Metadata.RemoteAsync]
IAsyncOperation<winrt::hstring> InvokeScriptAsync(winrt::hstring const& scriptName, IIterable<winrt::hstring> const& arguments);
[Windows.Foundation.Metadata.RemoteAsync]
public IAsyncOperation<string> InvokeScriptAsync(string scriptName, IEnumerable<string> arguments);
function invokeScriptAsync(scriptName, arguments)
Public Function InvokeScriptAsync (scriptName As String, arguments As IEnumerable(Of String)) As IAsyncOperation(Of String)
- scriptName
-
String
Platform::String
winrt::hstring
The name of the script function to invoke.
A string array that packages arguments to the script function.
An asynchronous operation object from which, on successful completion, you can retrieve the string result of the script invocation (or an empty string if the result of the script is not a string).
- Attributes
To prevent malicious code from exploiting your app, be sure to call this method to invoke only scripts that you trust.
The invoked script can return only string values. If the return value is not a string, an empty string is returned. For example, WebView.InvokeScriptAsync("eval", "1==1")
returns an empty string rather than true
, unless you use toString
: WebView.InvokeScriptAsync("eval", "(1==1).toString()")
.
Your app might appear unresponsive while scripts are running. Handle the LongRunningScriptDetected event to interrupt a long-running script.
Product | Versies |
---|---|
WinRT | Build 10240, Build 10586, Build 14383, Build 15063, Build 16299, Build 17134, Build 17763, Build 18362, Build 19041, Build 20348, Build 22000, Build 22621, Build 26100 |