0

I have one webview where some html content are display with some javascript and jquery and CSS. In this html content I have some anchor tag (...) with target="_blank" attribute. when I click on these links its open in same webview page but instead of doing this I want to open it into external browser. How is this possible in xamarin forms.

1 Answer 1

3

Catch Navigating Event on your webview and call Device.Open(your uri)

 webview.Navigating += (s, e) =>
            {
                if (e.Url.StartsWith("http"))
                {
                    try
                    {
                        var uri = new Uri(e.Url);
                        Device.OpenUri(uri);
                    }
                    catch (Exception)
                    {
                    }

                    e.Cancel = true;
                }
            };
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.