5

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.

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

StarlitSkies
  • 1,144
  • 7
  • 14

1 Answers1

8

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>

With

<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));
}
StarlitSkies
  • 1,144
  • 7
  • 14
  • Is there a similar way of doing this if you're not hosting the site yourself? – AndreasB Feb 02 '13 at 09:07
  • you can inject a script in the page if you don't host yourself by following this technique : http://blogs.msdn.com/b/wsdevsol/archive/2012/10/18/nine-things-you-need-to-know-about-webview.aspx#AN6 – Renaud Dumont Dec 18 '13 at 08:37