Hello... Need help with TWebBrowser (XE3, IE11, W10). I need to call events from Javascript to Delphi. I've found such Javascript:

Hello... Need help with TWebBrowser (XE3, IE11, W10). I need to call events from Javascript to Delphi. I've found such Javascript:

var event = document.createEvent('Event');
event.initEvent('somename', true, false);
...
someelement.dispatchEvent(evt);

Is it possible to listen this event in Delphi somehow? I have written IDispatch implementation and passed it to IHTMLElement2.attachEvent.

TIEEventObject = class(TInterfacedObject, IDispatch)
private
function getTypeInfoCount(out Count: Integer): HResult; stdcall;
function getTypeInfo(Index, LocaleID: Integer; out TypeInfo): HResult; stdcall;
function getIDsOfNames(const IID: TGUID; Names: Pointer; NameCount, LocaleID: Integer; DispIDs: Pointer): HResult; stdcall;
function invoke(DispID: Integer; const IID: TGUID; LocaleID: Integer; Flags: Word; var Params; VarResult, ExcepInfo, ArgErr: Pointer): HResult; stdcall;
end;

Unfortunately Invoke method is not being called.

Any suggestions? Thank you for ANY help!

Comments

  1. Probably, you can use OnNavigateError with different codes for different handlers.

    ReplyDelete
  2. Another way, maybe you can call JavaScript to access a variable in browser that its value is set by JavaScript in the browser at regular time.

    ReplyDelete
  3. Jack Lee Thank you, I've already handled it that way. :) But original question is still on...

    ReplyDelete

Post a Comment