Introduction:
We know that WebView is a view for displaying web and HTML content in your app. Due to security, sometimes we may need to restrict to open specific urls in our app.
Description:
In Xamarin.Forms, WebView raises the following events to help you respond to changes in state:
In MainPage.xaml
In MainPage.xaml.cs
async void OnNavigating(object sender, WebNavigatingEventArgs args)
{
// args.url will have new page url
if (args.Url == "https://google.com")
{
args.Cancel = true;
await DisplayAlert("Info", "This link was restricted to open in this app.", "Ok");
}
}
FeedBack Note: Please share your thoughts, what you think about this post, Is this post really helpful for you? I always welcome if you drop comments on this post and it would be impressive.
We know that WebView is a view for displaying web and HTML content in your app. Due to security, sometimes we may need to restrict to open specific urls in our app.
Description:
In Xamarin.Forms, WebView raises the following events to help you respond to changes in state:
- Navigating – event raised when the WebView begins loading a new page.
- Navigated – event raised when the page is loaded and navigation has stopped.
- ReloadRequested – event raised when a request is made to reload the current content.
In MainPage.xaml
- <WebView Navigating="OnNavigating" />
In MainPage.xaml.cs
FeedBack Note: Please share your thoughts, what you think about this post, Is this post really helpful for you? I always welcome if you drop comments on this post and it would be impressive.
No comments:
Post a Comment