-1

I have a website (I cannot change) having this script:

<input type="checkbox"  onclick="if (this.checked) openNew()">

function openNew() 
    { 
    window.open("/help?aide=77", "aproposde", "toolbar=no, location=no, directories=no, status=yes, scrollbars=yes, resizable=no, copyhistory=no, width=300, height=250, left=500, top=300"); 
    }

I try to use TWebBrowser, but on new window event, always opens an empty browser:

procedure TForm1.wwwNewWindow2(ASender: TObject; var ppDisp: IDispatch;
  var Cancel: WordBool);
var NF: TForm1;
begin
  NF := TForm1.Create(Application);
  NF.Visible := True;
  NF.www.RegisterAsBrowser;
  ppDisp := NF.www.DefaultInterface;
end;

Any idea how to solve that?

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
yarek
  • 11,278
  • 30
  • 120
  • 219
  • sorry: just paste that from another answer... and NF is the ONLY variable used here. So that's ok for 5 lines codes snippet ! – yarek Aug 26 '16 at 02:01
  • Sure. It's fine. Until next month, when that five line code snippet has grown into a 20 or 30 line procedure, and then six months later when someone other than you has to go in and try to read it and fix something. There's no excuse for sloppy code, even in five line code snippets. :-) – Ken White Aug 26 '16 at 02:05

1 Answers1

1

You can use NewWindow3 event as following

procedure TForm1.WebBrowser1NewWindow3(ASender: TObject; var ppDisp: IDispatch;
   var Cancel: WordBool; dwFlags: Cardinal; const bstrUrlContext, bstrUrl: WideString);
var NF: TForm1;
begin
  NF := TForm1.Create(Application);
  NF.Visible := True;       
  Cancel := True;
  NF.www.Navigate(bstrUrl);
end;
EugeneK
  • 2,164
  • 1
  • 16
  • 21