Search the web
Sign In
New User? Sign Up
delphi-webbrowser · Delphi: Using IE's WebBrowser
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Want your group to be featured on the Yahoo! Groups website? Add a group photo to Flickr.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
webbrowser and javascript   Message List  
Reply | Forward Message #10236 of 10267 |
Re: webbrowser and javascript

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
>





Mon Nov 3, 2008 4:15 pm

cedmart1_fr
Offline Offline
Send Email Send Email

Forward
Message #10236 of 10267 |
Expand Messages Author Sort by Date

I have de following HTML with Javascript code: <html> <head> <title>portais.htm</title> <script> function portal() { portais=new Array() portais[0]='Google'; ...
thelcio
Offline Send Email
Jan 16, 2008
3:42 pm

Study the samples in "files". I.e. "Pluggable Protocol" or "CustTagExample.zip". It's simple....
paurosooo
Offline Send Email
May 6, 2008
2:07 pm

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);...
cedmart1_fr
Offline Send Email
Nov 3, 2008
10:06 pm
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help