Can';t在通用应用程序中运行javascript警报';支付网关上的Web视图

Can';t在通用应用程序中运行javascript警报';支付网关上的Web视图,javascript,c#,webview,windows-phone-8.1,payment-gateway,Javascript,C#,Webview,Windows Phone 8.1,Payment Gateway,我正在将支付网关集成到我的通用windows应用程序中,在该应用程序中,我在网络视图中打开URL。但是,webview似乎无法显示javascript警报消息或弹出窗口。我在网上读到,我需要在软件包清单中添加网站的url,以使Scriptnotify事件能够运行,但鉴于它是一个支付网关,为所有银行网站添加url是不可行的。有办法解决这个问题吗 我也这样处理ScriptNotify事件,但这似乎部分是正确的 private async void MyWebView_ScriptNotify(ob

我正在将支付网关集成到我的通用windows应用程序中,在该应用程序中,我在网络视图中打开URL。但是,webview似乎无法显示javascript警报消息或弹出窗口。我在网上读到,我需要在软件包清单中添加网站的url,以使Scriptnotify事件能够运行,但鉴于它是一个支付网关,为所有银行网站添加url是不可行的。有办法解决这个问题吗

我也这样处理ScriptNotify事件,但这似乎部分是正确的

private async  void MyWebView_ScriptNotify(object sender, NotifyEventArgs e)
    {
        Windows.UI.Popups.MessageDialog dialog = new Windows.UI.Popups.MessageDialog(e.Value);

        await dialog.ShowAsync(); 
    }


private async void MyWebView_NavigationCompleted(WebView sender, WebViewNavigationCompletedEventArgs args)
    {
        string result = await this.MyWebView.InvokeScriptAsync("eval", new string[] { "window.alert = function (AlertMessage) {window.external.notify(AlertMessage)}" });

    }

在绞尽脑汁一两周后,终于找到了解决方案,以下是必要的事件处理程序:

private async void MyWebView_NavigationCompleted(WebView sender, WebViewNavigationCompletedEventArgs args)
    {
            string result = await this.MyWebView.InvokeScriptAsync("eval", new string[] { "window.confirm = function (ConfirmMessage) {window.external.notify(ConfirmMessage)}" });
    }


private async void MyWebView_ScriptNotify(object sender, NotifyEventArgs e)
    {

            Windows.UI.Popups.MessageDialog dialog = new Windows.UI.Popups.MessageDialog(e.Value);
            dialog.Commands.Add(new UICommand("Yes"));
            dialog.Commands.Add(new UICommand("No"));

            // Set the command that will be invoked by default
            dialog.DefaultCommandIndex = 0;

            // Set the command to be invoked when escape is pressed
            dialog.CancelCommandIndex = 1;

            var result = await dialog.ShowAsync();

            if (result.Label.Equals("Yes"))
            {
                string res = await MyWebView.InvokeScriptAsync("eval", new string[] { "window.confirm = function (ConfirmMessage) {return true}" });
            }
            else
            {
                string res = await MyWebView.InvokeScriptAsync("eval", new string[] { "window.confirm = function (ConfirmMessage) {return false}" });
            }
    }