rowternet
asked on
webbrowser1_documentcompleted is firing multiple times
Hi,
The webbrowser1_documentcomple ted is firing more than once(3 times).
Eventhough i am checking for ready state to be completed, it is not working.
I am using this code:
Try
If (WebBrowser1.ReadyState <> WebBrowserReadyState.Compl ete) Then
exit sub
Else
WebBrowser1.Document.Invok eScript("G etMap", New String() {"addr1", "addr2"})
End If
Any suggestions on how to prevent it firing more than once?
Thanks.
The webbrowser1_documentcomple
Eventhough i am checking for ready state to be completed, it is not working.
I am using this code:
Try
If (WebBrowser1.ReadyState <> WebBrowserReadyState.Compl
exit sub
Else
WebBrowser1.Document.Invok
End If
Any suggestions on how to prevent it firing more than once?
Thanks.
Use the ReadyState
Private Sub WebBrowser1_DocumentComple ted(ByVal sender As Object, ByVal e As System.Windows.Forms.WebBr owserDocum entComplet edEventArg s) Handles WebBrowser1.DocumentComple ted
If WebBrowser1.ReadyState = WebBrowserReadyState.Compl ete Then
'Completed
End If
End Sub
Private Sub WebBrowser1_DocumentComple
If WebBrowser1.ReadyState = WebBrowserReadyState.Compl
'Completed
End If
End Sub
ASKER
Hi,
Using e.url = webbrowser1.url ----- It does not fire multiple times. But iit is blocking the parameters sent to my map. For some reason the method is not seeing the parameters if i include this line
Using webbrowser1.readystate = webbrowserreadystate.compl ete ------ This is not helping. It is firing multiple times. But mymap and other methods are executing properly. This multiple execution is causing a problem as the map is displaying the same location multiple times.
Any other way to do this?
Thanks
Using e.url = webbrowser1.url ----- It does not fire multiple times. But iit is blocking the parameters sent to my map. For some reason the method is not seeing the parameters if i include this line
Using webbrowser1.readystate = webbrowserreadystate.compl
Any other way to do this?
Thanks
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi PaulHews,
I tried the above one. It did not work.
I have 2 questions:
1) How will i know how many frames are there on the document?
2) Can i call the browser.document.invokescr ipt in the form_load event? Or should i call it only in browser_documentcompleted event?
I tried to call it i the form_load event but it is not working. I need a confimation on this.
Thanks.
I tried the above one. It did not work.
I have 2 questions:
1) How will i know how many frames are there on the document?
2) Can i call the browser.document.invokescr
I tried to call it i the form_load event but it is not working. I need a confimation on this.
Thanks.
1. Are you sure frames are being used? Have you looked at the HTML source of the pages you are loading?
Try:
WebBrowser1.Document.Windo w.Frames.C ount
2. Form_Load is an event when your windows form loads. Seems unlikely you could do anything useful here.
>I tried the above one. It did not work.
If something doesn't work, you have to give a better picture of exactly what was tried and how it doesn't work.
Try:
WebBrowser1.Document.Windo
2. Form_Load is an event when your windows form loads. Seems unlikely you could do anything useful here.
>I tried the above one. It did not work.
If something doesn't work, you have to give a better picture of exactly what was tried and how it doesn't work.
Note that if your script is in a frame, you would need to invoke it from the right document... eg:
WebBrowser1.Document.Windo w.Frames(" frame_with _script"). Document.I nvokeScrip t("GetMap" , New String() {"addr1", "addr2"})
WebBrowser1.Document.Windo
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You can click "Accept and Award Points" on your own comment and award points to the experts as desired.
Open in new window