Francois et al,
I still have a problem with the line
Doc := wbZillower.Document as IHTMLDocument2; {***********}
In the procedure below because wbZillower.Document is always nil, no matter
What the URL line is.
How can I get wbZillower.Document to be non nil in the procedure below?:
const Header : string = 'http://www.zillow.com/homes/map/';
procedure TfmZillower.buNextClick(Sender: TObject);
var I : Integer;
URL : WideString;
Doc : IHTMLDocument2; // Current HTML document
HTMLWin : IHTMLWindow2; // Parent window of current HTML document
begin
Line := '';
{Get values of each address}
while (not Eof(AdrFile))
do begin
ReadLn(AdrFile,Line);
Line := Trim(Line);
if Line<>''
then begin
for I := 1 to Length(Line) do
if Line[I]=' '
then Line[I]:= '-';
URL := Header+Line+'_rb/';
meZillower.Text := URL;
wbZillower.Navigate( URL );
Doc := wbZillower.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( 'Javascript execution error: "'
+
JavaScriptExpression + '"');
end;
end;
end;
end;
end;
end;
end;
Sincerely,
Rich Cooper
EnglishLogicKernel.com
Rich AT EnglishLogicKernel DOT com
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf
Of Francois Piette
Sent: Wednesday, February 18, 2009 12:41 AM
To: Borland's Delphi Discussion List
Subject: Re: [TWebBrowser] Calling a JavaScript function
>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
You need MSHTML, SHDocVw and ActiveX.
--
[email protected]
Author of ICS (Internet Component Suite, freeware)
Author of MidWare (Multi-tier framework, freeware)
http://www.overbyte.be
-----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
_______________________________________________
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