How to cancel or dispose current navigation at WebBrowser element
Asked Answered
C

3

3

I am developing a C#, .NET Framework 4.0 application. It visits some pages with an order. Sometimes I have to move to the next page without waiting for the previous one to finish the job. How can I cancel the previous navigation process of the WebBrowser element?

WebBrowser element uses Internet Explorer. Thank you.

This is how I navigate

webBrowser1.Navigate("http://www.mywebsite.com/");
Collinsia answered 29/6, 2011 at 20:31 Comment(0)
E
5

WebBrowser.Stop Method

Elimination answered 29/6, 2011 at 20:36 Comment(0)
L
8

There's two immediate ways to do this. First, you could simply make a call somewhere in your code to the WebBrowser's Stop method. However, if you are looking for some more fine tuned control, you could wireup to the WebBrowser's Navigating event, and do something like this:

private void OnWebBrowserNavigating(object sender, WebBrowserNavigatingEventArgs e) {
    if (somecondition) {
        e.Cancel = true; // Cancels navigation
    }
}
Landgraviate answered 29/6, 2011 at 20:44 Comment(0)
E
5

WebBrowser.Stop Method

Elimination answered 29/6, 2011 at 20:36 Comment(0)
H
1

WebBrowser1.Stop()
I remember there being something like this. It cancels the current navigation.

Horoscopy answered 29/6, 2011 at 20:33 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.