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. CCSUOJ评测系统——第四次scrum冲刺

    1.小组成员 舒 溢 许嘉荣 唐 浩 黄欣欣 廖帅元 刘洋江 薛思汝 2.最终成果及其代码仓库链接 CCSU评测系统 代码仓库 3.评测系统功能 用户注册 用户可选题目进行提交 用户做题结果 排名功能 ...

  2. font-family:中文字体的英文名称 (宋体 微软雅黑)

    宋体 SimSun 黑体 SimHei 微软雅黑 Microsoft YaHei 微软正黑体 Microsoft JhengHei 新宋体 NSimSun 新细明体 PMingLiU 细明体 Ming ...

  3. Java简单方法批量修改Windows文件夹下的文件名(简单IO使用)

    package test.tttt; import java.io.File; import java.util.ArrayList; import java.util.List; public cl ...

  4. ORACLE DBA应该掌握的9个免费工具

      TOP1 : 录像机OS Watcher 如果说,作为一个Oracle维护工程师,你至少应该装一个工具在你维护的系统里,那么我首推这个.它就像银行自助取款机顶上的摄像头,默默的记录下你操作系统中的 ...

  5. 将Model对象转换成json文本或者json二进制文件

    将Model对象转换成json文本或者json二进制文件 https://github.com/casatwy/AnyJson 注意:经过测试,不能够直接处理字典或者数组 主要源码的注释 AJTran ...

  6. Celery学习--- Celery在项目中的使用

    可以把celery配置成一个应用,注意连接文件命名必须为celery.py 目录格式如下 项目前提: 安装并启动Redis CeleryPro/celery.py   [命名必须为celery.py] ...

  7. Build path entry is missing: config 引起的 The project: configwhich is referenced by the classpath, does not exist.

    运行Junit的时候报错, The project: XXXX which is referenced by the classpath, does not exist. 在Java Build Pa ...

  8. October 1st 2017 Week 40th Sunday

    It's only after we've lost everything that we're free to do anything. 只有我们失去了所有之后我们才能随心而为. After los ...

  9. 利用NET HUNTER建立一个自动文件下载的网络接入点

    免责声明:本文旨在分享技术进行安全学习,禁止非法利用. 本文中我将完整的阐述如何通过建立一个非常邪恶的网络接入点来使得用户进行自动文件下载.整个过程中我将使用 Nexus 9 来运行Kali NetH ...

  10. 4719: [Noip2016]天天爱跑步

    Time Limit: 40 Sec Memory Limit: 512 MB Submit: 1986 Solved: 752 [Submit][Status][Discuss] Descripti ...