-4

I am writing my auto submit tool on Delphi 6.

I am using TWebbroswer component to insert data to different controls.

However I need to be able to click on OK button on a pop-up window (this button appears after a javascript confirm command).

Is there any way I can click on this button from within my Delphi Application?

Toby Allen
  • 10,997
  • 11
  • 73
  • 124
  • 3
    I only upvoted your question because someone downvoted it without adding a reason. Welcome to Stackoverflow. As your question stands, it's of very poor quality and is unlikely to get you any responses. You've failed to show a code sample of what you've done and "How can I click this button" is not really a question. Please see the [FAQ](http://stackoverflow.com/faq) on how to ask questions, Stackoverflow-style – kolossus Dec 01 '12 at 19:22
  • 4
    @Kolossus, why are you voting up questions that are "of very poor quality" and "unlikely to get … responses"? That kind of question is *exactly* what negative votes are for. Pity votes aren't helpful. – Rob Kennedy Dec 01 '12 at 21:06
  • We cannot answer this unless you tell us a bit more. Show us the html for example. – Wouter van Nifterick Dec 01 '12 at 21:38
  • @RobKennedy if you ever want to get new users on Stackoverflow you need to give them guidance. – Toby Allen Dec 01 '12 at 21:55
  • @RobKennedy, I'm not upvoting for the benefit(or in pity) of OP. I upvote so if whoever downvoted it feels strongly enough about my actions, he'd come back and explain him/her voting and do the right thing, per stackoverflow ethos. I've upvoted to restore status quo because without an explanation, the downvote is meaningless. – kolossus Dec 01 '12 at 23:11
  • I think I had a similar question before, see solution [here][1] [1]: http://stackoverflow.com/questions/11885700/howto-simulate-click-ok-in-webbrowser-alert-messagebox-that-initiated-by-a-java – modzsi Jul 23 '14 at 23:40

1 Answers1

2

try this =)

procedure TForm1.Button1Click(Sender:Tobject);
begin
 EmbeddedWB1.Navigate('about:<input%20type=submit%20value="Click%20me!!!"%20onClick="alert(''Click!!!'');">');
end;

procedure TForm1.Button2Click(Sender: TObject);
var
Document:Variant;
Button:Variant;
I:Dword;
begin
 Document:=EmbeddedWB1.Document;
 for i:= 0 to Document.all.Length -1 do begin
   Button:=Document.all.item(I);
   if SameText(Button.tagName,'INPUT') then begin
     Button.Click;
     break;
   end;
 end;
end;
el Dude
  • 5,003
  • 5
  • 28
  • 40
  • 3
    The question asks how to click the button on the alert dialog. Your code presses an HTML button and displays a dialog box, but the question asks how to *dismiss* the dialog. – Rob Kennedy Dec 01 '12 at 21:06
  • @RobKennedy i wonder is the dialog was generated by MSIE or by JS. if latter he could override "alert()" function to do nothing. – Arioch 'The Dec 03 '12 at 07:24
  • @Rob Kennedy: author talk about "Ok button on pop-up ***window***", not dialog – el Dude Dec 03 '12 at 18:57