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. ubuntu14.04 忘记了登录密码和root密码

    由于很久没用自己的ubuntu了,发现刚想用时却忘记了密码,搞了半天终于搞好了,真的.... 在此记录一下自己的新密码:登录密码:1234567:ROOT密码:1234567 下面是整理网上的教程,亲 ...

  2. Forefront TMG 之 ISP 冗余传输链路(ISP-R)

    在 Forefront TMG 中,新增了ISP 冗余传输链路功能:在 TMG 中,你可以同时使用两条活动的外部链路,使用模式分为以下两种: 故障转移模式:在主要链路工作正常的情况下,所有的流量都通过 ...

  3. 【数据结构】 顺序表查找(折半查找&&差值查找)

    #include <stdio.h> #include <stdlib.h> #include <time.h> #define MAXSIZE 10 首先构造一个 ...

  4. Linux FFmpeg(含x264、lame插件)安装记录

    What is FFmpeg? FFmpeg是一套可以用来记录.转换数字音频.视频,并能将其转化为流的开源计算机程序.它提供了录制.转换以及流化音视频的完整解决方案. What is x264? H. ...

  5. PHP设计模式系列 - 解释器模式

    解释器模式 解释器模式 用于分析一个实体的关键元素,并且针对每个元素提供自己的解释或相应动作.解释器模式非常常用,比如PHP的模板引擎 就是非常常见的一种解释器模. 代码: <?php //解释 ...

  6. 高可用api接口网络部署方案

    我们平时接触的产品都是7*24小时不间断服务,产品中的api接口肯定也是高可用的,下面我向大家分享一下互联网公司api接口高可用的网络部署方案.  我们一般通过http://le.quwenzhe.c ...

  7. Git学习文档——文件状态git status

    1.已经跟踪的文件有三种状态 已跟踪的文件,即被纳入版本控制的文件,又分为未修改(unmodified).已修改(modified).已暂存(staged)三种状态. 如图: 当在工作目录中新加入一个 ...

  8. 【原创】Apache ab结果参数详解

    解释如下: Server Software 服务器软件软件名称. Server Hostname 被测服务器的主机名. Server Port 被测试的Web服务器的监听端口. SSL/TLS Pro ...

  9. 关于前端惰性加载(jquery_lazyload)的使用和原理分析

    1.前言 有时我们会有这样的需求,当网页有很多张图片的时候,我们不希望一次性就把图片加载完,而是希望当浏览器滑动到指定位置的时候再加载,这样可以节省带宽,它也能帮助减轻服务器负载.那么这种需求就需要利 ...

  10. Centos7安装anaconda3

    Centos7安装anaconda3 1. 安装bunzip2 yum install bunzip2 2. 下载anaconda3 wget https://repo.anaconda.com/ar ...