Your code seem good. but why u need to do
NewWindow.Show;
you window is not visible by default ?
did u try with
newWindow := TForm1.Create(application);
--- In delphi-webbrowser@yahoogroups.com, "thelcio" <htegina@...> wrote:
>
> I have de following HTML with Javascript code:
>
> <html>
> <head>
> <title>portais.htm</title>
> <script>
> function portal()
> {
> portais=new Array()
> portais[0]='Google';
> portais[1]='Yahoo';
> portais[2]='MSN';
>
> desc=new Array()
> desc[0]='Test AAAAA';
> desc[1]='Test BBBBB';
> desc[2]='Test CCCCC';
>
> for (i=0;i<portais.length;i++)
> {
> newPortais=document.createElement('div');
> newPortais.id=i;
> newPortais.innerHTML=portais[i];
> newPortais.onclick=function()
> {
> writeConsole(desc[this.id]);
> function writeConsole(content)
> {
> top.consoleRef=window.open('','myconsole',
> 'width=350,height=250'
> +',menubar=0'
> +',toolbar=1'
> +',status=0'
> +',scrollbars=1'
> +',resizable=1')
> top.consoleRef.document.writeln
> (
> '<html><head><title>Console</title></head>'
> +'<body bgcolor=yellow onLoad="self.focus()">'
> +content
> +'</body></html>'
> )
> top.consoleRef.document.close()
> }
> }
> divPortais.appendChild(newPortais);
> }
> }
> </script>
> </head>
>
> <body onload=portal()>
> <div id='divPortais' style='cursor: hand'></div>
> </body>
>
> </html>
>
> When I click in any item of the Portais array , the new window is
> opened showing the corresponding item in the desc array, but I am
> using a webbrowser component and want to open in a new form. So I
> tried this:
>
> unit NewWin;
>
> interface
>
> uses
> Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls,
> Forms,
> Dialogs, OleCtrls, SHDocVw;
>
> type
> TForm1 = class(TForm)
> WebBrowser1: TWebBrowser;
> procedure FormCreate(Sender: TObject);
> procedure WebBrowser1NewWindow2(Sender: TObject; var ppDisp:
> IDispatch;
> var Cancel: WordBool);
> private
> { Private declarations }
> public
> { Public declarations }
> end;
>
> var
> Form1: TForm1;
>
> implementation
>
> {$R *.dfm}
>
> procedure TForm1.FormCreate(Sender: TObject);
> begin
> WebBrowser1.Navigate('c:\nv\portais.htm');
> form1.Height:=90;
> end;
>
>
> procedure TForm1.WebBrowser1NewWindow2(Sender: TObject;
> var ppDisp: IDispatch; var Cancel: WordBool);
>
> var newWindow: TForm1;
>
> begin
> newWindow := TForm1.Create(self);
> newWindow.Top:=10;
> newWindow.Height:=200;
> newWindow.Width:=400;
> //NewWindow.BorderStyle:=bsnone;
> NewWindow.Show;
> ppDisp := NewWindow.Webbrowser1.DefaultDispatch;
> end;
> end.
>
> The new form is opened, shows the desc array content and the blank
> page is loaded.
> How can I show the items correctly?
> Thanks,
> Helcio
> Brasil
>