Share via


WebView.InvokeScriptAsync(String, IIterable<String>) Méthode

Définition

Exécute la fonction de script spécifiée à partir du code HTML actuellement chargé, avec des arguments spécifiques, en tant qu’action asynchrone.

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)

Paramètres

scriptName
String

Platform::String

winrt::hstring

Nom de la fonction de script à appeler.

arguments

IIterable<String>

IEnumerable<String>

IIterable<Platform::String>

IIterable<winrt::hstring>

Tableau de chaînes qui empaquette les arguments à la fonction de script.

Retours

IAsyncOperation<String>

IAsyncOperation<Platform::String>

IAsyncOperation<winrt::hstring>

Objet d’opération asynchrone à partir duquel, en cas d’achèvement réussi, vous pouvez récupérer le résultat de chaîne de l’appel de script (ou une chaîne vide si le résultat du script n’est pas une chaîne).

Attributs

Remarques

Pour empêcher le code malveillant d’exploiter votre application, veillez à appeler cette méthode pour appeler uniquement les scripts auxquels vous faites confiance.

Le script appelé peut retourner seulement des valeurs de chaîne. Si la valeur de retour n’est pas une chaîne, une chaîne vide est retournée. Par exemple, WebView.InvokeScriptAsync("eval", "1==1") retourne une chaîne vide au lieu de true, sauf si vous utilisez toString: WebView.InvokeScriptAsync("eval", "(1==1).toString()").

Votre application peut sembler ne pas répondre pendant l’exécution de scripts. Gérez l’événement LongRunningScriptDetected pour interrompre un script de longue durée.

S’applique à