简体   繁体   English

检测 WebView 中的 URL 何时更改 - Xamarin

[英]Detect when URL changes in WebView - Xamarin

It is my first time working with Xamarin, and need to show up a back button on the screen only when the URL of my WebView is different from the first one, so that the users can go back to the "home" page of the web site.这是我第一次使用 Xamarin,只有当我的 WebView 的 URL 与第一个不同时,才需要在屏幕上显示后退按钮,以便用户可以返回到 Web 的“主页”地点。 If there is any function that gets called once the page is completely loaded so I can get the URL and compare with the previos one would be great.如果有任何函数在页面完全加载后被调用,以便我可以获取 URL 并与之前的函数进行比较,那就太好了。 Thanks you!谢谢!

You could get the url from the event webView.Navigated您可以从事件webView.Navigated获取url

webView.Navigated += WebView_Navigated;
private void WebView_Navigated(object sender, WebNavigatedEventArgs e)
{
    var url = e.Url;
    //...
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM