How to call the OnChange event of “Select” ? (Delphi - WebBrowser)

后端 未结 2 479
盖世英雄少女心
盖世英雄少女心 2021-01-24 09:24

I\'m using Delphi and WebBrowser componenet to navigate a html page . the page have a Combobox . is there any way to call the OnChange event ?

The ComboBox is like this

相关标签:
2条回答
  • 2021-01-24 10:10

    to execute the onchange event you can use the execScript method

    check this sample

    uses
      MSHTML;
    
    var
      Doc: IHTMLDocument2;      
      HTMLWindow: IHTMLWindow2;           
    begin
      Doc := WebBrowser1.Document as IHTMLDocument2;
      if not Assigned(Doc) then
        Exit;
      HTMLWindow := Doc.parentWindow;
      if not Assigned(HTMLWindow) then
        Exit;
    
      HTMLWindow.execScript('yourfunctioname()', 'JavaScript'); 
    end;
    

    for more info check this excellent article

    • How to call JavaScript functions in a TWebBrowser from Delphi
    0 讨论(0)
  • 2021-01-24 10:21

    Inspired by the response. NET have been using the structures below:

    FrameSet Document Elements Item Name Value Change ;
    EWB.OleObject.Document.Frames.Item('mainFrame').Document.Forms.Item('invoiceForm').Elements.Item('inputname').Value:= '123456';
    

    or

    FrameSet Document Elements Items Lenth;
    
    EWB.OleObject.Document.Forms.Item('invoiceForm').Elements.Length;
    
    0 讨论(0)
提交回复
热议问题