弹来弹去跑马灯!

UWP Test Webview JS interact, new window open (新窗口打开)

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
using Newtonsoft.Json;
using System.Net.Http;
using System.Net;
// The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=402352&clcid=0x409

namespace App1
{
///


/// An empty page that can be used on its own or navigated to within a Frame.
///

public sealed partial class MainPage : Page
{
public MainPage()
{
this.InitializeComponent();
this.Loaded += MainPage_Loaded;
web.NewWindowRequested += Web_NewWindowRequested;//新窗口打开事件
}

private void Web_NewWindowRequested(WebView sender, WebViewNewWindowRequestedEventArgs args)
{
args.Handled = true;//
if (args.Uri != null && args.Uri.ToString() != "") {
new MessageDialog(""+ args.Uri, "tttt").ShowAsync();
}
}

private void MainPage_Loaded(object sender, RoutedEventArgs e)
{
web.NavigateToString("ttt



7777
test");
}

private async void web_ScriptNotify(object sender, NotifyEventArgs e)
{
var dialog = new ContentDialog()
{
Title = "????",
Content = ""+e.Value,
PrimaryButtonText = "??",
SecondaryButtonText = "??",
FullSizeDesired = false,
};

// dialog.PrimaryButtonClick += (_s, _e) => { loading.Visibility = Visibility.Visible; };
await dialog.ShowAsync();

}

private async void Button_Click(object sender, RoutedEventArgs e)
{
var x = web.InvokeScriptAsync("test", new string[] {"5555555" });
}
}
}

posted @ 2017-09-22 14:38  wgscd  阅读(482)  评论(0)    收藏  举报