Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. axWebBrowser DocumentComplete

axWebBrowser DocumentComplete

Scheduled Pinned Locked Moved C#
question
11 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Jasper4C

    Hi ! I need to know when my axWebBrowser finished the navigation to the web page. I hooked to .DoumentComplete event but it turns out that this event happens more than 1 time !?? (Why ?) So - how I can tell when the web page is completly loaded ?? "I have not failed. I've just found 10,000 ways that won't work." - Thomas Alva Edison (1847-1931)

    H Offline
    H Offline
    Heath Stewart
    wrote on last edited by
    #2

    See http://support.microsoft.com/support/kb/articles/q180/3/66.asp[^] for an explanation and a workaround. Basically, DocumentComplete is fired multiple times when a page contains references to multiple documents (i.e., frames). The easiest way is to is to see if the pDisp field of the DWebBrowserEvents2_DocumentCompleteEvent is the same reference as your AxWebBrowser instance. That'll signify that the top-level frame document has been loaded.

    Microsoft MVP, Visual C# My Articles

    1 Reply Last reply
    0
    • J Jasper4C

      Hi ! I need to know when my axWebBrowser finished the navigation to the web page. I hooked to .DoumentComplete event but it turns out that this event happens more than 1 time !?? (Why ?) So - how I can tell when the web page is completly loaded ?? "I have not failed. I've just found 10,000 ways that won't work." - Thomas Alva Edison (1847-1931)

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #3

      In a page with Frames, there are multiple web pages being used to render one visible page. There is a frames page that describes the layout of the view panes, then there is a seperate page for each of those panes. DocumentComplete will fire for every one of those pages that is downloaded, not just the frames page. You can use the uRL property of the eventargs to compare to the URL you sent the browser to. If the page has frames, the last URL to be returned will be the one you originally sent the browser to:

      Private Sub AxWebBrowser1\_DocumentComplete( \_
              ByVal sender As Object, \_
              ByVal e As AxSHDocVw.DWebBrowserEvents2\_DocumentCompleteEvent) \_
              Handles AxWebBrowser1.DocumentComplete
      

      If AxWebBrowser1.LocationURL = e.uRL Then
      MsgBox("Document Complete!")
      Else
      Debug.WriteLine("DocumentComplete received for URL: " & e.uRL)
      End If
      End Sub

      RageInTheMachine9532

      H D 2 Replies Last reply
      0
      • D Dave Kreskowiak

        In a page with Frames, there are multiple web pages being used to render one visible page. There is a frames page that describes the layout of the view panes, then there is a seperate page for each of those panes. DocumentComplete will fire for every one of those pages that is downloaded, not just the frames page. You can use the uRL property of the eventargs to compare to the URL you sent the browser to. If the page has frames, the last URL to be returned will be the one you originally sent the browser to:

        Private Sub AxWebBrowser1\_DocumentComplete( \_
                ByVal sender As Object, \_
                ByVal e As AxSHDocVw.DWebBrowserEvents2\_DocumentCompleteEvent) \_
                Handles AxWebBrowser1.DocumentComplete
        

        If AxWebBrowser1.LocationURL = e.uRL Then
        MsgBox("Document Complete!")
        Else
        Debug.WriteLine("DocumentComplete received for URL: " & e.uRL)
        End If
        End Sub

        RageInTheMachine9532

        H Offline
        H Offline
        Heath Stewart
        wrote on last edited by
        #4

        You copied and pasted VB.NET code from the MS KB into a C# forum? You should be punished. ;P

        Microsoft MVP, Visual C# My Articles

        J D 2 Replies Last reply
        0
        • H Heath Stewart

          You copied and pasted VB.NET code from the MS KB into a C# forum? You should be punished. ;P

          Microsoft MVP, Visual C# My Articles

          J Offline
          J Offline
          Jeremy Kimball
          wrote on last edited by
          #5

          "Get the whips and chains! Bind the heathen!" :)

          1 Reply Last reply
          0
          • H Heath Stewart

            You copied and pasted VB.NET code from the MS KB into a C# forum? You should be punished. ;P

            Microsoft MVP, Visual C# My Articles

            D Offline
            D Offline
            Dave Kreskowiak
            wrote on last edited by
            #6

            Yes and No... Yes, I pasted VB code into the C# Forum. AAAAAAAhhhhhh! My mistake! :doh: I should be flogged. It's not the exact code from the MS KB. I found that the code in the KB was for VB6 and didn't translate very well to VB.NET. The .Object property wouldn't compile. So I changed it to use the URL properties instead. It can be fooled by a redirection in the original page, but that's shouldn't be too much of a concern. RageInTheMachine9532

            H 1 Reply Last reply
            0
            • D Dave Kreskowiak

              Yes and No... Yes, I pasted VB code into the C# Forum. AAAAAAAhhhhhh! My mistake! :doh: I should be flogged. It's not the exact code from the MS KB. I found that the code in the KB was for VB6 and didn't translate very well to VB.NET. The .Object property wouldn't compile. So I changed it to use the URL properties instead. It can be fooled by a redirection in the original page, but that's shouldn't be too much of a concern. RageInTheMachine9532

              H Offline
              H Offline
              Heath Stewart
              wrote on last edited by
              #7

              Yeah, I know it's not a direct copy and paste. I've seen similar code around. :) But, yes, you should be flogged. :rose: ( oh, wait, I thought that was a cat-o-nine-tails... :doh: )

              Microsoft MVP, Visual C# My Articles

              1 Reply Last reply
              0
              • D Dave Kreskowiak

                In a page with Frames, there are multiple web pages being used to render one visible page. There is a frames page that describes the layout of the view panes, then there is a seperate page for each of those panes. DocumentComplete will fire for every one of those pages that is downloaded, not just the frames page. You can use the uRL property of the eventargs to compare to the URL you sent the browser to. If the page has frames, the last URL to be returned will be the one you originally sent the browser to:

                Private Sub AxWebBrowser1\_DocumentComplete( \_
                        ByVal sender As Object, \_
                        ByVal e As AxSHDocVw.DWebBrowserEvents2\_DocumentCompleteEvent) \_
                        Handles AxWebBrowser1.DocumentComplete
                

                If AxWebBrowser1.LocationURL = e.uRL Then
                MsgBox("Document Complete!")
                Else
                Debug.WriteLine("DocumentComplete received for URL: " & e.uRL)
                End If
                End Sub

                RageInTheMachine9532

                D Offline
                D Offline
                Dave Kreskowiak
                wrote on last edited by
                #8

                Whoops! How about a C# version...

                private void AxWebBrowser1_DocumentComplete(object sender, AxSHDocVw.DWebBrowserEvents2_DocumentCompleteEvent e)
                {
                if (AxWebBrowser1.LocationURL == e.uRL)
                {
                MsgBox("Document Complete!");
                }
                else
                {
                Degbug.WriteLine("DocumentComplete received for URL: " + e.uRL);
                }
                }

                My DEEPEST appologies to the C# community! :laugh: RageInTheMachine9532

                H 1 Reply Last reply
                0
                • D Dave Kreskowiak

                  Whoops! How about a C# version...

                  private void AxWebBrowser1_DocumentComplete(object sender, AxSHDocVw.DWebBrowserEvents2_DocumentCompleteEvent e)
                  {
                  if (AxWebBrowser1.LocationURL == e.uRL)
                  {
                  MsgBox("Document Complete!");
                  }
                  else
                  {
                  Degbug.WriteLine("DocumentComplete received for URL: " + e.uRL);
                  }
                  }

                  My DEEPEST appologies to the C# community! :laugh: RageInTheMachine9532

                  H Offline
                  H Offline
                  Heath Stewart
                  wrote on last edited by
                  #9

                  Okay, okay. Let me stitch you back up. ;P

                  Microsoft MVP, Visual C# My Articles

                  D 1 Reply Last reply
                  0
                  • H Heath Stewart

                    Okay, okay. Let me stitch you back up. ;P

                    Microsoft MVP, Visual C# My Articles

                    D Offline
                    D Offline
                    Dave Kreskowiak
                    wrote on last edited by
                    #10

                    Thank you master! :laugh: RageInTheMachine9532

                    N 1 Reply Last reply
                    0
                    • D Dave Kreskowiak

                      Thank you master! :laugh: RageInTheMachine9532

                      N Offline
                      N Offline
                      Nick Parker
                      wrote on last edited by
                      #11

                      Ok, this is starting to definately go off the bounds of programming! :rolleyes: - Nick Parker
                      My Blog | My Articles

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups