> 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