How can I intercept click on link within Webview?

Asked

Viewed 95 times

1

In my Android app, I have a webview that opens several different websites.

Everything works in the compliant, but when there is a link on the page, and the user clicks on this link, the browser opens.

I wonder if there is any click event on the elements that are inside the webview, or if there is some other way to treat these clicks inside the app.

My intention is to open everything inside the webview, so that the user does not leave the application

1 answer

0

Creates a Customwebview class that inherits from Webview and intercepts the click on the navigating event.

Ex:

    public class CustomWebView: WebView
    {
        public String Code { get; set; }

        public CustomWebView()
        {
            Navigating += CustomWebView_Navigating;
        }


        private void CustomWebView_Navigating(object sender, WebNavigatingEventArgs e)
        {
              //Faz alguma coisa
        }
    }

After a look at this link, maybe it will help you! https://stackoverflow.com/questions/38527183/xamarin-forms-handle-hyperlinks-in-webview-navigating-issue

Browser other questions tagged

You are not signed in. Login or sign up in order to post.