Catch a C # Web Browser Hyperlink

I have a webbrowser control in C # .NET CF.

When a user clicks on a hyperlink, instead of trying to go to the specified URL, how would instead display a fragment of the html content stored in memory?

I tried the following

//page doesnt refresh
private void webBrowser_Navigating(object sender, WebBrowserNavigatingEventArgs e)
{
    if (e.Url.Host != String.Empty) {
       e.Cancel = true;
       webBrowser.DocumentText = "<html> some text </html>";
    }
}

//some text appears but then the original page is loaded up
private void webBrowser_Navigating(object sender, WebBrowserNavigatingEventArgs e)
{
    if (e.Url.Host != String.Empty) {
       webBrowser.DocumentText = "<html> some text </html>";
    }
}
+3
source share
1 answer

I suggest trying to use webBrowser.Stop()in combination with an event Cancelthat completely stops navigation.

+2
source

Source: https://habr.com/ru/post/1709645/


All Articles