axWebBrowser DocumentComplete
-
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)
-
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)
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 thepDisp
field of theDWebBrowserEvents2_DocumentCompleteEvent
is the same reference as yourAxWebBrowser
instance. That'll signify that the top-level frame document has been loaded.Microsoft MVP, Visual C# My Articles
-
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)
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 SubRageInTheMachine9532
-
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 SubRageInTheMachine9532
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
-
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
"Get the whips and chains! Bind the heathen!" :)
-
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
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
-
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
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
-
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 SubRageInTheMachine9532
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
-
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
Okay, okay. Let me stitch you back up. ;P
Microsoft MVP, Visual C# My Articles
-
Okay, okay. Let me stitch you back up. ;P
Microsoft MVP, Visual C# My Articles
Thank you master! :laugh: RageInTheMachine9532
-
Thank you master! :laugh: RageInTheMachine9532
Ok, this is starting to definately go off the bounds of programming! :rolleyes: - Nick Parker
My Blog | My Articles