【转】Win10/UWP新特性系列—Web
Internet Explorer
Internet Explorer 在Windows 10 升级为Edge模式,是一种交互性和兼容性都很强的新型浏览器,该浏览器相比以前的版本更新了超过2000个操作性问题,支持20个新平台特性来促进交互性和兼容性。详情: http://blogs.msdn.com/b/ie/archive/2014/11/11/living-on-the-edge-our-next-step-in-interoperability.aspx
WebView Edge mode Browsing
所有Windows 10 系统下的WebView控件使用了相同的浏览器渲染引擎,提供了 统一的html标准。
WebView.UnsupportedUriSchemeIdentified event
新增的WebView.UnsupportedUriSchemeldentified事件能够让WebView捕获到不受支持的uri地址,让我们开发者提供处理这些不受支持的URI方案。
XAML:
C#:
private void OnUnsupportedUriSchemeIdentified (WebView sender, WebViewUnsupportedUriSchemeIdentifiedEventArgs e)
{
// Block all URIs from invoking other apps except the mailto: protocol.
if (e.Uri.Scheme != "mailto")
{
e.Handled= true;
}
}
WebView.NewWindowsRequested event
WebView.NewWindowsRequested事件能在WebView捕获脚本请求一个新的浏览器窗口动作。默认情况下当用户点击一个href或者按钮调用Windows.Open时,会启动默认浏览器来打开请求的导航,现在开发者可以自己捕获该动作,自行处理业务逻辑。
例子中,捕获该事件后创建一个新的WebView控件来显示所请求的内容:
XAML:
C#:
private void OnNewWindowRequested (WebView sender, WebViewNewWindowRequestedEventArgs e)
{
if (e.Referrer.Host == "www.xxxxxx.com")
{
var newWebView = new WebView();
newWebView.Navigate(e.Uri);
myGrid.Children.Add(newWebView);
e.Handled = true;
}
}
WebView.PermissionRequested event
WebView支持最新的Html5技术,有些Html5 Api的调用是需要用户授权的,比如获取地理位置Api,而WebView.PermissionRequested事件能捕捉要求用户许可授权的动作。
WebView.UnviewableContentIdentified event
WebView.UnviewableContentIdentified 事件可以捕获到WebView尝试下载不受支持的文件时发生,当捕捉到该事件后你可以自行处理此事件 并使用Launcher类将文件重定向到浏览器或者其他应用程序。
例子:
C#:
void webView1_UnviewableContentIdentified(WebView sender,
WebViewUnviewableContentIdentifiedEventArgs args)
{
appendLog(String.Format("Content for "{0}" cannot be loaded into webview. " +
"Invoking the default launcher instead.\n", args.Uri.ToString()));
// We turn around and hand the Uri to the
// system launcher to launch the default handler for it.
Windows.Foundation.IAsyncOperation<bool> b =
Windows.System.Launcher.LaunchUriAsync(args.Uri);
pageIsLoading = false;
}
WebView.AddWebAllowedObject method
该方法可以在WebView中添加一个Windows RunTime对象到html Document对象中。该对象必须集成IAgileObject接口并附加AllowForWeb特性。
例子:
C#:
private void navigationStarting(WebView sender, WebViewNavigationStartingEventArgs args)
{
if (args.Uri.Host == "www.contoso.com")
{
myWebView.AddWebAllowedObject("name", new MyClass());
}
}
WebView.ClearTemporaryWebDataAync method
该方法能清除WebView中保存的用户会话状态和缓存数据,来防止另一个用户访问到以前的数据。例如,当用户注销登录时,你可以使用该方法清理WebView控件该用户会话的任何信息。
来自:http://www.wangchenran.com/uwp新技术-web.html
【转】Win10/UWP新特性系列—Web的更多相关文章
- Win10/UWP新特性系列—Launcher实现应用间的通信
UWP中,微软为Windows.System.Launcher启动器新增了很多的功能,以前只能启动App,打开指定扩展名文件,对uri协议的解析,以及当启动的应用没有安装时则会提示前往商店下载等. 如 ...
- Win10/UWP新特性系列—使用打印机
微软在Win10时代终于完成的设备系统的大统一,"56个民族,56支花……"(⊙o⊙)…,既然统一了,那么也就意味着API也统一了,所以在UWP中,我们就可以使用统一的打印API来 ...
- Win10/UWP新特性系列-GetPublisherCacheFolder
微软Windows Runtime App拥有很强的安全模型来防止不同App之间的数据获取和共享,也就是我们所说的"沙盒机制",每个App都运行在Windows沙盒中,App之间的 ...
- Win10/UWP新特性系列—电池报告
UWP中,新增了当节电模式开启时,App能获取到通知的API,通过响应电源条件的更改,比如咨询用户是否使用黑色背景等来帮助延长电池使用时间. 通过Windows.Devices.Power命名空间中的 ...
- Win10/UWP新特性—Drag&Drop 拖出元素到其他App
在以前的文章中,写过微软新特性Drag&Drop,当时可能由于处于Win10预览版,使用的VS也是预览版,只实现了从桌面拖拽文件到UWP App中,没能实现从UWP拖拽元素到Desktop A ...
- Win10/UWP新特性—SharedStorageAccessManager 共享文件
首先先给大家推荐一个UWP/Win10开发者群:53078485 里面有很多大婶,还有很多学习资源,欢迎大家来一起讨论Win10开发! 在UWP开发中,微软提供了一个新的特性叫做SharedStor ...
- 返璞归真 asp.net mvc (10) - asp.net mvc 4.0 新特性之 Web API
原文:返璞归真 asp.net mvc (10) - asp.net mvc 4.0 新特性之 Web API [索引页][源码下载] 返璞归真 asp.net mvc (10) - asp.net ...
- atitit。win7 win8 win9 win10 win11 新特性总结与战略规划
atitit.win7 win8 win9 win10 win11 新特性总结与战略规划 1. win7 1 1.1. 发布时间 2009年10月22日 1 1.2. 稳定性大幅提升,很少蓝屏死机 ...
- Java8新特性系列-默认方法
Java8 Interface Default and Static Methods 原文连接:Java8新特性系列-默认方法 – 微爱博客 在 Java 8 之前,接口只能有公共抽象方法. 如果不强 ...
随机推荐
- 软工读书笔记 week 7 ——《构建之法》
总时长近两周的结对项目终于算是结束了,马上要重新开启团队项目.于是这几天决定对<构建之法>一书中与团队项目及需求分析有关的章节进行重点阅读,希望能够从中得到启发,并运用到接下来的团队项目中 ...
- Script:诊断解析等待和高version count
select * from (select sql_id, count(child_number) from v$sql_shared_cursor group by sq ...
- 铁乐学Python_day12_装饰器
[函数的有用信息] 例: def login(user, pwd): ''' 功能:登录调用 参数:分别有user和pwd,作用分别是用户和密码: return: 返回值是登录成功与否(True,Fa ...
- Linux--安全加固01
Redhat是目前企业中用的最多的一类Linux,而目前针对Redhat攻击的黑客也越来越多了.我们要如何为这类服务器做好安全加固工作呢? 一. 账户安全 1.1 锁定系统中多余的自建帐号 检查方法: ...
- Apache2.2 + tomcat7 服务器集群配置
1.软件安装 1.1下载和安装apache Apache 2.2 :http://httpd.apache.org/download.cgi,下载msi安装程序,选择no ssl版本 1.2下载和安装 ...
- 使用Oracle的instr函数与索引配合提高模糊查询的效率
使用Oracle的instr函数与索引配合提高模糊查询的效率 一般来说,在Oracle数据库中,我们对tb表的name字段进行模糊查询会采用下面两种方式:1.select * from tb wher ...
- Python之Web2py框架使用
本文主要是对Web2py框架的介绍和安装使用. 一. 介绍 全栈式Web框架:Web2py是 Google 在 web.py 基础上二次开发而来的,兼容 Google App Engine .是一个为 ...
- AdminLTE前端模板
AdminLTE是一个Bootstrap框架模板,其功能组件并不比我直接提到的Metronic差. 第一次接触过AdminLTE是在学习Jeesite这个开源项目的时候.离现在已经有半年了. Admi ...
- two sum[easy]
Given an array of integers, return indices of the two numbers such that they add up to a specific ta ...
- 初识Qt窗口界面
1.新建一个新的Qt Gui应用,项目名称随意,例如MyMainWindow,基类选择QMainWindow,类名为MainWindow. 2.项目建立后,双击mainwindow.ui文件,在界面的 ...