Lucas Nunes Lucas Nunes - 9 months ago 49
HTML Question

Close dialog window on webpage

I need to trigger some actions inside one webpage (not mine)..

I have got this code so far:

IHTMLElementCollection DeleteCollection =

foreach (HTMLAnchorElement buttonDelete in DeleteCollection){
if (buttonDelete.title != null && buttonDelete.title.StartsWith("Delete")){;
// problem goes here;

The dialog that pops up is this: image

As you can see above, I tried:;

and also:


But, the dialog seems to be out of the page, and I don't know how to trigger the

Any help will be welcome, thanks in advance.


You cannot close a browser dialog programatically. What you can do is hijack browser popup behavior. This might work for you:

window.confirm=function(){ return true; };
window.alert=function(){ return true; };
window.prompt=function(){ return "textOfMyChoice"; };

Basically, insert this javascript before clicking your buttons. If you want to later restore the popup behavior store them in another global variable.