Reputation: 1110
I am working on a Xamarin.Forms PCL project. I am trying to display posts in a WebView using custom HTML to make hashtags clickable using an anchor tag.
An example of the HTML would be
<html><p>Check out </p><a>@HelloWorld</a></html>
I am trying to make it so when the anchor tag is clicked it runs some C# code to navigate to the page to display the tag.
Navigation.PushAsync(ProfilePage("helloworld"));
I tried looking for a way with href but I couldn't find anything.
Upvotes: 0
Views: 292
Reputation: 381
From webview you can get the value of the navigating url which you have mentioned in href or something from the below method.
<a href="something">@something</a> //in html
void OnNavigating(object sender, WebNavigatingEventArgs e)
{
e.Cancel = true;
Debug.WriteLine("URL received after navigated123: {0}", e.Url);
/* do your ProfilePage(Joe) stuff here */
Navigation.PushAsync(ProfilePage(e.Url));
}
You will get that something
in e.Url
.
Hope at-least this helps.
Upvotes: 1
Reputation: 4632
I would suggest that you check out Firebase Dynamic links: https://firebase.google.com/products/dynamic-links/
This allow you to navigate users to any location within your app by clicking web links, app links, etc.
Hope this helps!
Upvotes: 2