Hello,
For Android platform, you can do this by adding custom renderer for your webview and set SetSupportMultipleWindows
to false. Then you can open the url when you click the hyper-link.
assembly: ExportRenderer(typeof(Xamarin.Forms.WebView), typeof(MyWebviewRenderer))]
namespace HTMLandWebview.Droid
{
public class MyWebviewRenderer : WebViewRenderer
{
public MyWebviewRenderer(Context context) : base(context)
{
}
protected override void OnElementChanged(ElementChangedEventArgs<Xamarin.Forms.WebView> e)
{
base.OnElementChanged(e);
if (e.NewElement != null)
{
Control.Settings.SetSupportMultipleWindows(false);
}
}
}
}
By the way, I use your html code like following code-snap.
var htmlSource = new HtmlWebViewSource();
htmlSource.Html = @"<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<p>A quiz on this Lent bible story can be <a href=""https://www.catholicbrain.com/edu-video/51274/quiz/920614/lent-36---the-parable-of-the-tenant-farmers"" target=""_blank"">found here</a>.</p>
\r\n\r\n
<center>
<h4>Take the 40 Day Bible Journey Challenge!</h4>
</center>
\r\n
<center>
<h4>Day 31 - Zerubbabel Rebuilds the Temple </h4>
</center>
\r\n
<div class=""video-responsive""><iframe src=""https://player.vimeo.com/video/434426534"" width=""640"" height=""360"" frameborder=""0"" webkitallowfullscreen="""" mozallowfullscreen="""" allowfullscreen=""""></iframe></div>
\r\n
<p>A quiz on this bible story can be <a href=""https://www.catholicbrain.com/edu-video/1266144/quiz/1266164/day-31---zerubbabel-rebuilds-the-temple"" target=""_blank"">found here</a>.</p>
\r\n\r\n
<center>
<h4>Enjoy our ongoing daily Bible series.</h4>
</center>
\r\n
<center>
<h4>Old Testament 88 - Samson Dies </h4>
</center>
\r\n
<div class=""video-responsive""><iframe src=""https://player.vimeo.com/video/323838087"" width=""640"" height=""360"" frameborder=""0"" webkitallowfullscreen="""" mozallowfullscreen="""" allowfullscreen=""""></iframe></div>
\r\n
<p>A quiz on this Old Testament bible story can be <a href=""https://www.catholicbrain.com/edu-video/811434/quiz/812674/ot-088---samson-dies"" target=""_blank"">found here</a>.</p>
</body>
</html>";
web_view.Source = htmlSource;
For iOS platform, it is working.
Best Regards,
Leon Lu
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.