drus9
asked on
Verify that the webbrowser has fully loaded a web page
Hey all,
i have script that opens the browser,navigates to a webpage & insures that the webpage has fully loaded by using
Do while mIE.readystate < 4
DoEvents
Loop
before running anything else. this works fine
My problem is after running this i want to be able to navigate to a diffrent webpage without closing the browser and insure that this new webpage has fully loaded before running anything else.
Any Help would realy be appreciated
Reg,
drus9
i have script that opens the browser,navigates to a webpage & insures that the webpage has fully loaded by using
Do while mIE.readystate < 4
DoEvents
Loop
before running anything else. this works fine
My problem is after running this i want to be able to navigate to a diffrent webpage without closing the browser and insure that this new webpage has fully loaded before running anything else.
Any Help would realy be appreciated
Reg,
drus9
You can use the DownloadComplete event of the WebBrowser control.
ASKER
Tried it not giving reliable results
Declare a form level variable (mintPage) to track which page you are processing, then:
Option Explicit
Private mintPage As Integer
Private Sub WebBrowser1_DocumentComple te(ByVal pDisp As Object, URL As Variant)
Select Case mintPage
Case 1
'Code to run after 1st page loaded
Case 2
'Code to run after 2nd page loaded
End If
End Sub
This is very reliable. I use this code all the time to auto-navigate series of links. You need to keep track of which page you are processing through the mintPage variable.
Option Explicit
Private mintPage As Integer
Private Sub WebBrowser1_DocumentComple
Select Case mintPage
Case 1
'Code to run after 1st page loaded
Case 2
'Code to run after 2nd page loaded
End If
End Sub
This is very reliable. I use this code all the time to auto-navigate series of links. You need to keep track of which page you are processing through the mintPage variable.
Show us your code.
Private Sub WebBrowser1_DocumentComple te(ByVal pDisp As Object, URL As Variant)
if (pDisp is webbrowser1) then
' do what you want
msgbox "Full loaded"
end if
End Sub
Another way (I don't believe in it , eally)
do until webbrowser1.busy<>true
doevents
loop
' continue with your code here........
if (pDisp is webbrowser1) then
' do what you want
msgbox "Full loaded"
end if
End Sub
Another way (I don't believe in it , eally)
do until webbrowser1.busy<>true
doevents
loop
' continue with your code here........
ASKER
just sample code of what i'm doing but getting unreliable results.
Private Sub web_DocumentComplete(ByVal pDisp As Object, URL As Variant)
Select Case webPage
Case 1
web.Navigate "www.something.com"
Case 2
web.Document.All("username ").Value = " dgshshsh"
web.Document.All("password ").Value = "dgdhdhshs"
web.Document.Forms(submit_ form).subm it
btnClick "OK"
Case 3
web.Navigate "www.somethingelse.com"
Case 4
web.Document.All("username ").Value = "dghdhdhdc"
web.Document.All("password ").Value = "dhdjdjd"
web.Document.Forms(submit_ form).subm it
End Select
webPage = webPage + 1
End Sub
Private Sub web_DocumentComplete(ByVal
Select Case webPage
Case 1
web.Navigate "www.something.com"
Case 2
web.Document.All("username
web.Document.All("password
web.Document.Forms(submit_
btnClick "OK"
Case 3
web.Navigate "www.somethingelse.com"
Case 4
web.Document.All("username
web.Document.All("password
web.Document.Forms(submit_
End Select
webPage = webPage + 1
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Excellent point Richie. The event will fire for each frame that is fully loaded and only when the entire page is loaded will the (pDisp is webbrowser1) be true.
You are right, Paul!
:)
:)
ASKER
Cheers Richie
Cheers to you too and thanks for the points!