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("<html><title>ttt</title><body><br/><br/><br/><br/><div id='t' style='font-size:25px;color:red;'>7777</div>test<script type='text/javascript'>alert(99);window.external.notify('hello');function test(s){t.innerText=s;}</script></body></html>");
} 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" });
}
}

}

UWP Test Webview JS interact, new window open (新窗口打开)的更多相关文章

  1. location.href 本窗口与window.open 新窗口打开用法

    二种新窗口打开的区别: window.open("URL",'top'); 只是表示打开这个页面,并不是打开并刷新页面: window.location.href="UR ...

  2. JS~模拟表单在新窗口打开,避免广告拦截

    说起广告拦截,这应该是浏览器的一个特性,它会将window.open产生的窗口默认为一个广告,将它进行拦截,但有时,这不是我们所希望的,有时,我们就是需要它在客户端的浏览器上弹出一个新窗口,以展示数据 ...

  3. JS判断鼠标进入容器方向的方法和分析window.open新窗口被拦截的问题

    1.鼠标进入容器方向的判定 判断鼠标从哪个方向进入元素容器是一个经常碰到的问题,如何来判断呢?首先想到的是:获取鼠标的位置,然后经过一大堆的if..else逻辑来确定.这样的做法比较繁琐,下面介绍两种 ...

  4. 防止浏览器拦截的window.open新窗口方案

    背景 当前的浏览器为了保证用户体验,在很多场合下禁止了window.open打开新窗口,下面就给出一些方案,最大程度上的实现新窗口打开一个链接. 方案 //打开新链接方法实现 function win ...

  5. javascript新窗口打开链接window.open()被阻拦的解决办法

    场景是ajax提交,比较后端效验数据,需要用户登录,提示后并需要新窗口打开登录的链接,使用window.open(url);往往会被浏览器认为是广告而被拦截. data.url是ajax返回的链接地址 ...

  6. 【JS学习】慕课网2-7 练习题:制作新按钮,“新窗口打开网站” ,点击打开新窗口。

    要求: 1.新窗口打开时弹出确认框,是否打开 提示: 使用 if 判断确认框是否点击了确定,如点击弹出输入对话框,否则没有任何操作. 2.通过输入对话框,确定打开的网址,默认为 http://www. ...

  7. 在js中实现新窗口打开页面

    我们都知道可以在html代码中使用<a href="xxxx" target="_blank"></a>这种方式来打开一个新的窗口打开一 ...

  8. js 新窗口打开

    <script> function tj(){ window.open ('http://www.baidu.com', 'newwindow', 'height=500px, width ...

  9. IE和其他浏览器用JS新窗口打开的问题

    Chrome中 window.open(pageURL,name,parameters) pageURL 为子窗口路径 name 为子窗口句柄 parameters 为窗口参数(各参数用逗号分隔) 例 ...

随机推荐

  1. zabbix系列之四——快速使用

    https://www.zabbix.com/documentation/3.4/manual/quickstart/login Quickstart 1login and configuring u ...

  2. STL中set和map

    set 可以认为是数学上的集合,集合中的元素不允许有重复.set特有的操作是高效的插入.删除和执行基本查找. set的插入方法是 insert,由于集合元素的唯一性,insert操作不一定会成功,in ...

  3. 创建和修改 ExpressRoute 线路

    本文介绍如何使用 Azure 门户和 Azure Resource Manager 部署模型创建 Azure ExpressRoute 线路. 以下步骤还说明如何查看线路状态,以及如何更新.删除和取消 ...

  4. [C# | XML] XML 反序列化解析错误:<xml xmlns=''> was not expected. 附通用XML到类解析方法

    使用 XML 反化时出现错误: public static TResult GetObjectFromXml<TResult>(string xmlString) { TResult re ...

  5. show tables from information_schema/performance_schema/sys;

    root@localhost:3306.sock [performance_schema]>select version();+------------+| version()  |+----- ...

  6. 使用UISearchDisplayController

    使用UISearchDisplayController 虽然UISearchDisplayController名字中带有controller,可他不是一个UIView相关的controller,因为, ...

  7. AVAudioPlayer简易封装

    AVAudioPlayer简易封装 [说明] AVAudioPlayer简易封装,仅仅支持播放,暂停,停止,暂停时候带有渐隐效果,自己用,没有参考价值. [源码] https://github.com ...

  8. 前端 网络三剑客之html 02

    html 四.表单标签 form标签: input系列:内敛标签 1.明文: 姓名:<input type="text" name="user" plac ...

  9. Linux 系统的日志目录

    连接时间的日志 连接时间日志一般由/var/log/wtmp和/var/run/utmp这两个文件记录,通过who查看 who /var/log/wtmp [连接时间日志] who /var/log/ ...

  10. windows server 2016部署服务

          绪论 有时候,如果安装系统数量比较多,而且数量较多,人工使用U盘或者光盘安装,效率较低,通过网络可以批量安装. 还可以做到无人安装. PXE PXE(preboot execute env ...