Bruno Yu - MSFT
timmytong,
According to your question on closing Javascript alert, I would like to provide you the suggestions as follows:
1. WebBrowser.Navigated Event occurs when the WebBrowser has navigated to a new document and has begun loading it while DocumentCompleted Event occurs when finishes loading a document. In my opinion, they are not good enough to close the Javascript alerts.
2. You can try to use SendKeys.Send method to send the "Enter" keystroke to close the alert automatically when the alert happens, the following code snippet shows you the way:
Code Block
' Use the SendKeys.Send method to raise the Button1 click event
' and display the message box.
Private Sub Form1_DoubleClick(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.DoubleClick
' Send the enter key; since the tab stop of Button1 is 0, this
' will trigger the click event.
SendKeys.Send("{ENTER}")
End Sub
3. The following thread with the answers provided by Arun and anxvariety can help you on the issue:
I used HWND of the IE application and used GetLastActivePopup to identify the active pop window for IE application and used PostMessage to send ok to alert.
alerthwnd = GetLastActivePopup(iehwnd);
if (alerthwnd && (alerthwnd != iehwnd)) {
PostMessage(iehwnd, 0x113, 1, 0);
}
Anyone who is looking for a solution to this - I found a solution and thought I'd return here and post it, hopefully it helps someone!
See the following link:
http://vbcity.com/forums/topic.asp tid=108859
Hope that can help you.