|
-
Oct 25th, 2003, 07:16 PM
#1
Thread Starter
Addicted Member
Web Browser complete
how whould i initate a set a events after the web broswer is done loading a page. The page has to load completly before the events happen. How whould i do this.
-
Oct 26th, 2003, 04:41 AM
#2
have you not tried NavigateComplete2 then? or is it missing something / triggering before the page has finished loading?
VB Code:
[Color=Blue]Private[/COLOR] [Color=Blue]Sub[/COLOR] AxWebBrowser1_NavigateComplete2([Color=Blue]ByVal[/COLOR] sender [Color=Blue]As[/COLOR] [Color=Blue]Object[/COLOR], [Color=Blue]ByVal[/COLOR] e [Color=Blue]As[/COLOR] AxSHDocVw.DWebBrowserEvents2_NavigateComplete2Event) [Color=Blue]Handles[/COLOR] AxWebBrowser1.NavigateComplete2
[Color=Green]'///[/COLOR] [Color=Green]use[/COLOR] [Color=Green]the[/COLOR] [Color=Green]NavigateComplete2[/COLOR] [Color=Green]Sub[/COLOR] [Color=Green]to[/COLOR] [Color=Green]handle[/COLOR] [Color=Green]events[/COLOR] [Color=Green]for[/COLOR] [Color=Green]a[/COLOR] [Color=Green]browser[/COLOR] [Color=Green]when[/COLOR] [Color=Green]it's[/COLOR] [Color=Green]completed[/COLOR] [Color=Green]loading.
[/COLOR] [Color=Blue]End[/COLOR] [Color=Blue]Sub[/COLOR]
hope thats the one your after.
~
if a post is resolved, please mark it as [Resolved]
protected string get_Signature(){return Censored;}
[vbcode][php] please use code tags when posting any code [/php][/vbcode]
-
Oct 26th, 2003, 12:23 PM
#3
Thread Starter
Addicted Member
The events that I put in the private sub you posted happens before the page even starts to load.
-
Oct 26th, 2003, 01:54 PM
#4
well thats the sub that triggers upon a webpage being loaded, maybe if you specified the url within that sub and only carry out your code if it's navigated to that page it would work. like...
VB Code:
[COLOR=blue]If[/COLOR] AxWebBrowser1.LocationUrl = " Site name here " [COLOR=blue]Then[/COLOR]
[COLOR=green]'///carry out your code here.[/COLOR]
[COLOR=blue]Else[/COLOR]
[COLOR=green]'/// Do nothing.[/COLOR]
[COLOR=blue]End If[/COLOR]
~
if a post is resolved, please mark it as [Resolved]
protected string get_Signature(){return Censored;}
[vbcode][php] please use code tags when posting any code [/php][/vbcode]
-
Oct 26th, 2003, 11:37 PM
#5
Thread Starter
Addicted Member
I Still run into the problem of not KNowing how long it takes a page to load on someone elses computer. Theres got to be a way to make navigate2 work here is my code:
VB Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
name12 = TextBox1.Text
url = "http://www.outwar.com/playersearch.php?search=" & name12 & "&submit=Search"
Web1.Navigate(url)
Label17.Text = name12
End Sub
Private Sub web1_NavigateComplete2(ByVal sender As Object, ByVal e As AxSHDocVw.DWebBrowserEvents2_NavigateComplete2Event) Handles Web1.NavigateComplete2
Web1.Navigate("www.yahoo.com")
End Sub
All this does is keep reloading yahoo.
-
Oct 27th, 2003, 01:19 AM
#6
That is because by calling navigate inside the Navigatecomplete2 event you make it recursive. In other words everytime the page at yahoo.com finishs loading it calls the complete event which in turn then calls for another yahoo page. You can listen to dynamic and inside the complete event check the url and only navigate again if its not yahoo. The code he posted would be put it the Complete event.
-
Oct 27th, 2003, 01:26 AM
#7
Thread Starter
Addicted Member
ok i see, but is there a way to use navigate 2 to detect when the browser is done loading?
-
Oct 27th, 2003, 01:29 AM
#8
The NavigateComplete2 event only fires when a page (any page) finishes loading. Well any page loaded into the associated AxWeb Browser control.
-
Oct 27th, 2003, 01:37 AM
#9
Thread Starter
Addicted Member
So how to I make the cose i posted above work?
-
Oct 27th, 2003, 01:39 AM
#10
How is it broken? Or what is it suppose to do?
-
Oct 27th, 2003, 01:42 AM
#11
Thread Starter
Addicted Member
it keeps loading yahoo and doesnt load the url variable first. What i really need to do is navigate to url then after that is finished loading get the html(i know how to do this)
-
Oct 27th, 2003, 01:43 AM
#12
VB Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
name12 = TextBox1.Text
url = "http://www.outwar.com/playersearch.php?search=" & name12 & "&submit=Search"
Web1.Navigate(url)
Label17.Text = name12
End Sub
Private Sub web1_NavigateComplete2(ByVal sender As Object, ByVal e As AxSHDocVw.DWebBrowserEvents2_NavigateComplete2Event) Handles Web1.NavigateComplete2
'put your code to get html here
End Sub
If you don't want it to go to yahoo then why is that there? I'm confused.
-
Oct 27th, 2003, 01:47 AM
#13
Thread Starter
Addicted Member
I put it there to see what page it whould load first, the page i wanted or the page that was under naviagte2. BUt any way when i use this code the events under navigate2 always happen first.
-
Oct 27th, 2003, 01:51 AM
#14
Huh? Also regarding your test, as soon as the first page loaded then it would immediately change to the yahoo page so it doesn't really work also the yahoo page doesn't get called until after the first one is loaded in fact that is what fires it so the one in the button call will always load first.
-
Oct 27th, 2003, 01:52 AM
#15
Thread Starter
Addicted Member
When you say loaded do you mean loaded completly or just starting?
-
Oct 27th, 2003, 01:57 AM
#16
Thread Starter
Addicted Member
For Example is this instance the msgbox is displayed first and ok must be pressed before the page is even starting to load
VB Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
name12 = TextBox1.Text
url = "http://www.outwar.com/playersearch.php?search=" & name12 & "&submit=Search"
Web1.Navigate(url)
Label17.Text = name12
End Sub
Private Sub web1_NavigateComplete2(ByVal sender As Object, ByVal e As AxSHDocVw.DWebBrowserEvents2_NavigateComplete2Event) Handles Web1.NavigateComplete2
msgbox("Test")
End Sub
-
Oct 27th, 2003, 02:00 AM
#17
I think we should understand first when I say loaded I mean it is downloaded, the browser may still be rendering or showing it but it should be completely downloaded or loaded. So the msgbox may halt the thread from showing the page but it 'should' be completed or completely loaded (aka downloaded). In other words the webbrowser should have all of the html from the source.
-
Oct 27th, 2003, 02:02 AM
#18
Thread Starter
Addicted Member
So you are saying that i can download the html even though the broswer is still rendering?
-
Oct 27th, 2003, 02:06 AM
#19
That 'should' be the case.
-
Oct 27th, 2003, 02:06 AM
#20
Thread Starter
Addicted Member
ok thanks, thats what i needed to know
-
Oct 27th, 2003, 05:58 AM
#21
if you want the source of the html , use Document_Complete not Navigate_Complete. eg:
VB Code:
[Color=Blue]Private[/COLOR] [Color=Blue]Sub[/COLOR] AxWebBrowser1_DocumentComplete([Color=Blue]ByVal[/COLOR] sender [Color=Blue]As[/COLOR] [Color=Blue]Object[/COLOR], [Color=Blue]ByVal[/COLOR] e [Color=Blue]As[/COLOR] AxSHDocVw.DWebBrowserEvents2_DocumentCompleteEvent) [Color=Blue]Handles[/COLOR] AxWebBrowser1.DocumentComplete
[Color=Green]'///[/COLOR] [Color=Green]doc[/COLOR] [Color=Green]is[/COLOR] [Color=Green]completely[/COLOR] [Color=Green]loaded[/COLOR] [Color=Green]now
[/COLOR] MessageBox.Show(AxWebBrowser1.Document.documentelement.innerhtml)
[Color=Blue]End[/COLOR] [Color=Blue]Sub[/COLOR]
~
if a post is resolved, please mark it as [Resolved]
protected string get_Signature(){return Censored;}
[vbcode][php] please use code tags when posting any code [/php][/vbcode]
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
|