Francois,
What unit has to be in the "uses" clause to define the two vars:
Doc : IHTMLDocument2; // Current HTML document
HTMLWin : IHTMLWindow2; // Parent window of current HTML document
Sincerely,
Rich Cooper
EnglishLogicKernel.com
Rich AT EnglishLogicKernel DOT com
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf
Of Francois Piette
Sent: Monday, February 16, 2009 7:25 AM
To: Borland's Delphi Discussion List
Subject: Re: [TWebBrowser] Calling a JavaScript function
> I have the following problem: Having a web page loaded into a TWebBrowser
> hosted in my Delphi application, I want to have Delphi code execute a
> JavaScript function embedded in the HTML page. How can I do that ?
Answering my own question:
procedure WB_ExecScript(WebBrowser: TWebBrowser; JavaScriptExpression :
String);
var
Doc : IHTMLDocument2; // Current HTML document
HTMLWin : IHTMLWindow2; // Parent window of current HTML document
begin
Doc := WebBrowser.Document as IHTMLDocument2;
if Assigned(Doc) then begin
HTMLWin := Doc.parentWindow;
if Assigned(HTMLWin) then begin
try
HTMLWin.execScript(JavaScriptExpression, 'JavaScript');
except
on E:Exception do begin
ShowMessage('Erreur d''exécution JavaScript de "' +
JavaScriptExpression + '"');
end;
end;
end;
end;
end;
--
[email protected]
Author of ICS (Internet Component Suite, freeware)
Author of MidWare (Multi-tier framework, freeware)
http://www.overbyte.be
_______________________________________________
Delphi mailing list -> [email protected]
http://lists.elists.org/cgi-bin/mailman/listinfo/delphi
_______________________________________________
Delphi mailing list -> [email protected]
http://lists.elists.org/cgi-bin/mailman/listinfo/delphi