I have a sample application in Xamarin.form, which use to showing local HTML content in webview.
I want to use the navigation event to change the content of webview.
It working fine in Android but in IOS not getting navigation URL. In IOS navigation getting the full path of IOS application like...
file://locationpathofIOSapplication/WorkingWithWebviewiOS.app
public class LocalHtml : ContentPage
{
public LocalHtml()
{
var browser = new WebView();
var htmlSource = new HtmlWebViewSource();
htmlSource.Html = @"<html><body>
<h1 onclick=""window.location='Navigation://yahoo'"">Xamarin.Forms</h1>
</br> </br></br>
<a href=""Navigation://google""> Click on me</a>
</br> </br></br>
<p>Welcome to WebView Test Navigation.</p>
</body>
</html>";
browser.Source = htmlSource;
Content = browser;
browser.Navigated += Browser_Navigated;
}
private void Browser_Navigated(object sender, WebNavigatedEventArgs e)
{
string url = e.Url;
if(url == "google")
{
//do some action
}
else if(url == "yahoo")
{
//do some action
}
}
}