|
-
May 15th, 2008, 12:26 PM
#1
Thread Starter
Lively Member
[2005] WebBrowser, DocumentCompleted, Navigating, Navigated
Hey guys, I'm going to try and explain this as best I can. I tried before but it was kind of a failure. 
I have an application that controls webbrowsers, using the .net webbrowser control. On the form with the webbrowser, I have a boolean variable, "DocCompleted".
When I instruct the browser to navigate somewhere, I set the DocCompleted to be false. The DocumentCompleted event of the WebBrowser then does this:
Code:
Private Sub WebBrowser_DocumentCompleted(ByVal sender As Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser.DocumentCompleted
If e.Url.ToString = WebBrowser.Url.ToString Then
Me.DocCompleted = True
End If
End Sub
So what happens is each time the documentcompleted event is fired, it checks to see if the url of the event is the same as the url as the browser. This is because when you have frames on the page the DocumentCompleted event fires once for each frame and then one more time when the entire document is completed. Obviously I want to wait for the entire document and not just the first frame. I just have to wait until DocCompleted = true and when it is the page has loaded and I can continue on. This code has been working well for me.
The Problem: Some webpages use an Iframe that's a geotarget script and it just hangs for ever and ever and ever. It never fires a documentcompleted event that I can tell, and thus the last document completed event never fires either.
This is what I tried:
Code:
Private Sub WebBrowser_Navigating(ByVal sender As Object, ByVal e As System.Windows.Forms.WebBrowserNavigatingEventArgs) Handles WebBrowser.Navigating
If Equals(e.Url.Authority, Nothing) Or Equals(Me.WebBrowser.Url.Authority, Nothing) Then Exit Sub
If Not Equals(e.Url.Authority, Me.WebBrowser.Url.Authority) Then
e.cancel
End If
End Sub
The idea was if the frame it's trying to load is not on the same root domain as the page, just cancel navigation for that frame all together. Unfortunatetly this doesn't fire the documentcompleted either. I tried firing it manually with no real luck there either.
I know this is long winded and complicated, but, any ideas?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|