Qu'est-ce que je fais mal?Comment obtenir un message d'alerte de site Web UWP WebView
J'ai utilisé w3schools.com pour les tests.
webView.Navigate(new Uri("https://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_alert"));
fichier Package.appxmanifest
NavigationCompleted
private async void webView_NavigationCompleted(WebView sender, WebViewNavigationCompletedEventArgs args)
{
string result = await sender.InvokeScriptAsync("eval", new string[] { "window.alert = function (AlertMessage) {window.external.notify(AlertMessage)}" });
}
ScriptNotify
private async void WebView_ScriptNotify(object sender, NotifyEventArgs e)
{
MessageDialog dialog = new MessageDialog(e.Value);
await dialog.ShowAsync();
}
Qu'espérez-vous arriver, et que fait-il à la place? – Adam
Je veux recevoir un message d'alerte [comme ceci (capture d'écran)] (https://i.stack.imgur.com/IHbud.png) –