我做錯了什麼?如何獲取任何網站的警報消息UWP WebView
我用w3schools.com進行測試。
webView.Navigate(new Uri("https://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_alert"));
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();
}
你期望發生的,並且它在幹什麼呢? – Adam
我想獲得警報消息[像這樣(截圖)](https://i.stack.imgur.com/IHbud.png) –