albundy
asked on
waiting while webbrowser busy ?
hi,
another question....
I have a prog that submit a form then once submitted it load a welcome page, at this way I want to go back.
I use this :
[submitting form.....]
Do
DoEvents
Loop Until Not WebBrowser1.Busy
WebBrowser1.GoBack
it give me an error :
method error, goback failed....
I think the function don't wait enough until the page is fully loaded...
is there any sure way to wait until the page be fully loaded ?
Regards,
Oliver
another question....
I have a prog that submit a form then once submitted it load a welcome page, at this way I want to go back.
I use this :
[submitting form.....]
Do
DoEvents
Loop Until Not WebBrowser1.Busy
WebBrowser1.GoBack
it give me an error :
method error, goback failed....
I think the function don't wait enough until the page is fully loaded...
is there any sure way to wait until the page be fully loaded ?
Regards,
Oliver
Isn't there a NavigateComplete property?
yup...
try:
Do While WebBrowser1.NavigateComple te = false
DoEvents
Loop
Do While WebBrowser1.NavigateComple
DoEvents
Loop
ASKER
don't work...
it didn't recognize this function :(
it didn't recognize this function :(
ASKER
Isn't there a NavigateComplete property?
yep there is but didn't work too.... it doesn't wait the full load of the page
yep there is but didn't work too.... it doesn't wait the full load of the page
You should use the Document_Complete event
Private Sub WebBrowser1_DocumentComple te(ByVal pDisp As Object, URL As Variant)
If URL = "Your Target URL" Then WebBrowser1.GoBack
End Sub
You don't need to use a loop or anything this way.
Private Sub WebBrowser1_DocumentComple
If URL = "Your Target URL" Then WebBrowser1.GoBack
End Sub
You don't need to use a loop or anything this way.
ASKER
already tryed it... don't work too.... :(
is there any way to tell vb to wait 1 second or more ?
is there any way to tell vb to wait 1 second or more ?
Use this in your code
Public Declare Sub Sleep Lib "kernel32" Alias "Sleep" (ByVal dwMilliseconds As Long)
Vin.
Public Declare Sub Sleep Lib "kernel32" Alias "Sleep" (ByVal dwMilliseconds As Long)
Vin.
ASKER
doesn't seems to work too :(
does sleep do events ? or does it stop all process ?
anyway it is not a good solution I think....
if anyone have a working code....pleaze :)
does sleep do events ? or does it stop all process ?
anyway it is not a good solution I think....
if anyone have a working code....pleaze :)
TimCottee's solution should work. but go ahead and try:
Do While WebBrowser.ReadyState <> READYSTATE_COMPLETE
DoEvents
Loop
and just put an On Error Resume Next statement in the sub calling the GoBack method...the error being thrown may not even affect the operation.
Do While WebBrowser.ReadyState <> READYSTATE_COMPLETE
DoEvents
Loop
and just put an On Error Resume Next statement in the sub calling the GoBack method...the error being thrown may not even affect the operation.
How many MilliSeconds did you wait for.
Sleep just waits for the specified number of milliseconds before returning.
Vin.
Sleep just waits for the specified number of milliseconds before returning.
Vin.
ASKER
sleep stop processing and that's not what I want
any way azrasound function give me an error with doc.form...
I used my previous version
Do
DoEvents
Loop Until Not WebBrowser1.Busy
seems to be good enough.... I puted a timer, that seems to be the best.... but of course bug sometime :(
thx anyway...
any way azrasound function give me an error with doc.form...
I used my previous version
Do
DoEvents
Loop Until Not WebBrowser1.Busy
seems to be good enough.... I puted a timer, that seems to be the best.... but of course bug sometime :(
thx anyway...
doc.form??
ASKER
yup, I use it to submit data to a form...
well that should not be related to anything i posted, but oh well, looks like you found your best solution. good luck to you.
Try this :
-------------------------- ---------- ---------- ------
Dim bBackEnabled as Boolean
'for loading a page
Sub LoadPage(ByVal sURL As String)
WebBrowser1.Navigate sURL
Do
'putting additional DoEvents ... don't bother
'WebBrowser control too frequently
DoEvents
DoEvents
DoEvents
Loop Until Not WebBrowser1.Busy
End Sub
'for going back
Sub GoBack()
Do
DoEvents
DoEvents
DoEvents
Loop Until Not bBackEnabled
WebBrowser1.GoBack
End Sub
'for keeping track of the back button state
Private Sub WebBrowser1_CommandStateCh ange _
(ByVal Command As Long, ByVal bEnable As Boolean)
If (Command = 2) Then 'back button
bBackEnabled = bEnable
End If
End Sub
-------------------------- ---------- ---------- ------
Let me know if this solved your problem.
- Vikram
--------------------------
Dim bBackEnabled as Boolean
'for loading a page
Sub LoadPage(ByVal sURL As String)
WebBrowser1.Navigate sURL
Do
'putting additional DoEvents ... don't bother
'WebBrowser control too frequently
DoEvents
DoEvents
DoEvents
Loop Until Not WebBrowser1.Busy
End Sub
'for going back
Sub GoBack()
Do
DoEvents
DoEvents
DoEvents
Loop Until Not bBackEnabled
WebBrowser1.GoBack
End Sub
'for keeping track of the back button state
Private Sub WebBrowser1_CommandStateCh
(ByVal Command As Long, ByVal bEnable As Boolean)
If (Command = 2) Then 'back button
bBackEnabled = bEnable
End If
End Sub
--------------------------
Let me know if this solved your problem.
- Vikram
Hi albundy,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:
Refund points and save as a 0-pt PAQ.
albundy, Please DO NOT accept this comment as an answer.
EXPERTS: Post a comment if you are certain that an expert deserves credit. Explain why.
==========
DanRollins -- EE database cleanup volunteer
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:
Refund points and save as a 0-pt PAQ.
albundy, Please DO NOT accept this comment as an answer.
EXPERTS: Post a comment if you are certain that an expert deserves credit. Explain why.
==========
DanRollins -- EE database cleanup volunteer
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.