How to capture a navigation event in a web browser in Windows 8?

I have a Webview application in my application, and I want to intercept any clicks and open links in IE, and not inside the web view in the application.

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

+4
source share
1 answer

It seems that no navigation events exist. However, you can intercept script events called in JavaScript with window.external.notify ()

Assuming the page is what you accept, 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 will 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)); } 
+7
source

Source: https://habr.com/ru/post/1437142/


All Articles