0

Is there anyone here knows how to handle the alert message from WebBrowser (Alert).

Here is the scenario, i login to a specific website, then when login thing is done, there is an alert message generated by Javascript. My problem is that i can't close the Alert Message through codes. Thanks.

RB.
  • 36,301
  • 12
  • 91
  • 131

2 Answers2

0

The alert box in JavaScript is completely client-driven and you won't be able to access it from the server-side. Unfortunately there's no real way to "force close" an alert or confirm dialog box, even utilizing JavaScript. Is there any specific reason you need to close this alert box and, better yet, can't you modify the login code in C# to NOT generate the alert box?

FarligOpptreden
  • 5,013
  • 22
  • 23
  • I believe he is using the WebBrowser class in C#. See http://msdn.microsoft.com/en-us/library/system.windows.forms.webbrowser.aspx – RB. Feb 15 '12 at 08:48
  • I am creating a bot for Web, like auto-login, auto-download files, etc. Problems are those annoying pop-up messages. when pop-up appears, the whole process freeze or waiting for end user input. – Apes Jaguar Feb 17 '12 at 05:11
0

You can try to read up the document body and via DOM manipulation remove that javascript block (or any block that contains it).

Hope that helps.

Digvijay
  • 361
  • 1
  • 9