it sounds pretty, but it wont work
checked this:
procedure TForm1.wbNewWindow2(Sender
var Cancel: WordBool);
var
wn:variant;
wh,ww:longint;
begin
wn:=ppdisp;
wh:= wn.height; // here it shooted an error
ww:= wn.width;
// wn.url
// wn.name
showmessage(inttostr(wh) + ' - ' + inttostr(ww));
end;
twebbrowser newwin parameters
--------------------------
<a href="#" onClick="window.open('Foto
PICTURE</a>
--------------------------
when i have on the page link as here, it will open the new browser window with some modified properties - width, height, ...
can i in onBeforeNavigate determine a values of this parameters?
to this time, i used this restriction in our pages:
--------------------------
<a href="#" onClick="window.open('P129
PICTURE</a></td>
--------------------------
... all parameters are opied to the url, but this is wery "huge" solution, i dislike it.
the best solution would be a direct access.
Jump to Answer
ID: 20131871Comments
Expert Comment
Here is the correction
Try this:
procedure TForm1.wbNewWindow2(Sender
var Cancel: WordBool);
var
wn:variant;
wh,ww:longint;
begin
wn:=ppdisp;
wh:= wn.document.body.clientWid
ww:= wn.document.body.clientHei
// wn.url
// wn.name
showmessage(inttostr(wh) + ' - ' + inttostr(ww));
end;
Accepted Solution
This will provide some of the functionality you are looking for. It does not prevent resizing or scrollbars. Scrollbars can be prevented in the pages you are displaying though using: <body scroll="no">
This creates a new instance of the IE Browser through automation. This gives you access to the automation properties that it exposes. With the following procedure you can control the NewWindow2 event.
Add MSHTML to your uses clause.
NewWindow2 Procedure:(Captures/Cancel
procedure TForm1.DynamicWBNewWindow2
var Cancel: WordBool);
var
Doc: IHTMLDocument2;
sURL: string;
Flags: OLEVariant;
begin
Flags := 0;
begin
Cancel := True;
Doc := IHTMLDocument2(TWebBrowser
sURL := Copy(Doc.activeElement.out
Doc.activeElement.outerHTM
pos('href=', Doc.activeElement.outerHTM
sURL := Copy(sURL, 0, pos('>', sURL) - 1);
if pos('"', sURL) = 1 then
sURL := Copy(sURL, 2, Length(sURL) - 1);
if pos('"', sURL) <> 0 then
sURL := Copy(sURL, 0, pos('"', sURL));
if pos('"', sURL) = Length(sURL) then
sURL := Copy(sURL, 0, Length(sURL) - 1);
OpenIE(sURL);
Flags);
end;
end;
Add comobj to the uses clause.
This is where we create the New Browser window.
procedure OpenIE(aURL: string);
var
IE: Variant;
WinHanlde: HWnd;
begin
if (VarIsEmpty(IE)) then //See if we already have our window open if not open and navigate
begin
IE := CreateOleObject('InternetE
IE.MenuBar := False;
IE.AddressBar := False;
IE.StatusBar := False;
IE.ToolBar := 0;
IE.Height := 500;
IE.Width := 620;
IE.Visible := true;
IE.Navigate(aURL);
end
else
begin
WinHanlde := FindWIndow('IEFrame', nil);// Must already have a window try to open
if (0 <> WinHanlde) then
begin
try
IE.Navigate(aURL);
SetForegroundWindow(WinHan
except
try // Was closed but we did not know it. Unassign and try again.
IE := Unassigned;
except
end;
OpenIE(aURL);
end;
end
else
ShowMessage('Can''t open IE !');
end;
end;
Rick
Expert Comment
If you are using the TWebBrowser then you are already using an instance of the original IE. You are just using the Delphi Wrapper Component to do it. If you have a TWebBrowser and click a link that opens a new window(or use window.open) then it will be creating another instance of IE. My solution intercepts the new window event(TWebBrowser.NewWindo
Rick
by: f15iaf on 2001-06-08 at 04:09:42ID: 6167269
Try to use onnewwindow2 event:
var
win:variant;
begin
win:=ppdisp;
you can get all the values
win.height;
win.width
win.url
win.name
and so on
cancel:=true;
to open a new window use
win.open(.......);
.
.
.
.
.
end;