WinRt WebView 控件处理控件内的导航 [英] WinRt WebView control handling navigation within the control

查看:24
本文介绍了WinRt WebView 控件处理控件内的导航的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用 WebView 控件的 Metro 应用程序.我正在使用 NavigateToString 加载可能包含超链接的 html 文件.然后我想要做的是检测何时选择了这些超链接之一,而不是允许在 WebView 控件中导航,而是启动 IE 并在那里查看页面.

I have a Metro app using a WebView control. I'm using NavigateToString to load a html file which may contain hyperlinks. What I then want to do is detect when one of these hyperlinks is selected and, instead of allowing navigation within the WebView control, to launch IE and view the page there instead.

这在 WinRT 限制范围内是否可行,如果可以,如何实现?

Is this possible within the WinRT constraints, and if so, how?

到目前为止,我已尝试捕获 WebView_LoadCompleted() 事件,但尽管它确实在正确的时间触发,但我无法从 NavigationEventArgs 中看到有关 URI 的任何详细信息.

So far, I've tried capturing the WebView_LoadCompleted() event, but although it does fire at the right time, I can't see any details about the URI from the NavigationEventArgs.

推荐答案

不幸的是,这无法直接实现,因为 WebView 不包括 Navigating 等事件(Windows Phone 中存在这些事件).

Unfortunately this isn't possible directly because WebView does not include events like Navigating (which were present in Windows Phone).

幸运的是 Nick Randolph(杰出的 Windows Phone 和 Windows 8 开发人员)使用脚本事件创建了一个解决方法.他在他的博客上写了一篇很棒的文章:

Luckily Nick Randolph (brilliant Windows Phone and Windows 8 developer) has created a workaround using script events. He's got a great write up on his blog:

http:///nicksnettravels.builttoroam.com/post/2012/04/21/Limitations-of-the-WebView-in-Windows-8-Metro-Apps.aspx

这篇关于WinRt WebView 控件处理控件内的导航的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆