我如何捕获网页视图导航事件在Windows 8? [英] How do I capture a navigation event in a webview on Windows 8?

查看:104
本文介绍了我如何捕获网页视图导航事件在Windows 8?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的应用程序网页视图,我想拦截任何水龙头打开IE浏览器,而不是网页视图内的应用程序的链接。

I have a Webview in my app and I want to intercept any taps and open the links in IE rather than inside the Webview in the app.

我只能看到有关我可以拦截一个关于导航事件NavigationFailed和LoadingComplete事件,什么都没有。

I can only see NavigationFailed and LoadingComplete events, nothing regarding an "about to navigate" event which I could intercept.

推荐答案

似乎有ISN ŧ任何方式捕捉任何导航事件。但是,您可以拦截调用的JavaScript与window.external.notify()

It seems there isn't any way to catch any navigation events. However, you can intercept script events called in JavaScript with window.external.notify()

脚本事件假设页面是你正在举办自己,你可以替换

Assuming the page is something you're hosting yourself, you can replace

<a href="http://www.lightwoodgames.com">LINK</a>

通过

<a href="javascript:window.external.notify('http://www.lightwoodgames.com')">LINK</a>



然后在你的项目,你需要添加

Then in your project you'll want to add

webview.ScriptNotify += webview_ScriptNotify;
webview.AllowedScriptNotifyUris = WebView.AnyScriptNotifyUri;

protected async void webview_ScriptNotify(object sender, NotifyEventArgs e)
{
  await Windows.System.Launcher.LaunchUriAsync(new Uri(e.Value));
}

这篇关于我如何捕获网页视图导航事件在Windows 8?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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