【转】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 之前,接口只能有公共抽象方法. 如果不强 ...
随机推荐
- Debian出现in the drive ‘/media/cdrom/’ and press enter解决办法
没有光盘源解决打开/etc/apt/sources.list文件,注释掉cdrom那一行,然后再执行apt-get update更新下deb仓库这样以后再使用apt-get安装时就不会再搜寻cdrom ...
- JVM知识(二):类加载器原理
我们知道我们编写的java代码,会经过编译器编译成字节码(class文件),再把字节码文件装载到JVM中,最后映射到各个内存区域中,我们的程序就可以在内存中运行了.那么问题来了,这些字节码文件是怎么装 ...
- leetCode题解 Student Attendance Record I
1.题目描述 You are given a string representing an attendance record for a student. The record only conta ...
- 产品经理都知道MVP,但是它可能不再是产品研发最好的模型了
产品经理都知道MVP,但是它可能不再是产品研发最好的模型了 孟小白Aspire • 2017-09-01 • 汽车交通 要简单.讨喜.完整,不要最小可行性产品.这对创业公司的第一个产品来说很重要. M ...
- 3.如何在Maven项目中引入自己的jar包
1.一般情况下jar包都可以使用pom.xml来配置管理,但也有一些时候,我们项目中使用了一个内部jar文件,但是这个文件我们又没有开放到maven库中. 我们会将文件放到我们项目中.(以下以java ...
- .net验证是否合法邮箱和ip地址的方式
通常情况下第一时间会想到使用正则表达式去验证,但由于正则表达式过于复杂或者没有考虑到某些情况,从而导致问题或者判断的效率低.下面通过另一种方式去判断. 判断是否合法邮箱: /// <summar ...
- 一些centos 6和centos 7的区别
CentOS 6(OLE 6,RHEL 6类似) CcnetOS 7(OLE 7,RHEL 7类似) 影响 默认文件系统 ext4 xfs 大量小文件在ext4上工作性能较好在64位linux中, ...
- [翻译] CNPPopupController
CNPPopupController CNPPopupController is a simple and versatile class for presenting a custom popup ...
- Python3.5 执行发邮件Exchangelib(=)
fyl Python发邮件的代码如下: 只需要填写好加粗字体,即可正常使用. from exchangelib import DELEGATE, Account, Credentials, Messa ...
- November 20th 2016 Week 47th Sunday
Learn from yesterday, live for today, look to tomorrow. 学习昨天,活在今天,展望明天. There is always room at the ...