• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 561
  • Last Modified:

twebbrowser newwin parameters

------------------------------------------------
<a href="#" onClick="window.open('Foto_album/pondelok_26_2001/P1290421.jpg','okno','width=620,height=500,toolbar=no,location=no,directories=no,status=no,scrollbars=no,copyhistory=no,noresize')">
     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('P1290414.jpg?width=620,height=510,toolbar=no,location=no,directories=no,status=no,scrollbars=no,copyhistory=no,noresize','okno','width=620,height=500,toolbar=no,location=no,directories=no,status=no,scrollbars=no,copyhistory=no,noresize')">
     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.
0
pistacer
Asked:
pistacer
  • 14
  • 8
  • 2
  • +1
1 Solution
 
f15iafCommented:
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;
0
 
pistacerAuthor Commented:
it sounds pretty, but it wont work

checked this:

procedure TForm1.wbNewWindow2(Sender: TObject; var ppDisp: IDispatch;
  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;
0
 
f15iafCommented:
Here is the correction
Try this:
procedure TForm1.wbNewWindow2(Sender: TObject; var ppDisp: IDispatch;
 var Cancel: WordBool);
var
 wn:variant;
 wh,ww:longint;
begin
 wn:=ppdisp;
 wh:= wn.document.body.clientWidth;
 ww:= wn.document.body.clientHeight;
//  wn.url
//  wn.name
 showmessage(inttostr(wh) + ' - ' + inttostr(ww));
end;
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
pistacerAuthor Commented:
no, no, no ... :-(((

do not works ... but i tried the first style (wn.height) in onbeforenavigate2 and there it do not raises an errror and when pdisp = webbrowser1.application, then the walues are not zero and are correctr. :-))))

wich object is passed thru pdisp? it aint window, nor document. i am asking because i would like to determine the ohers walues (toolbar, location, directories, status, menubar ...) and they can be text or boolean typed and under other names stored..

0
 
RickHalleCommented:
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/Cancels the NewWindow2 URL and strips it down to just the URL without the target then uses OPENIE)

procedure TForm1.DynamicWBNewWindow2(Sender: TObject; var ppDisp: IDispatch;
  var Cancel: WordBool);
var
  Doc: IHTMLDocument2;
  sURL: string;
  Flags: OLEVariant;
begin
  Flags := 0;
  begin
    Cancel := True;
    Doc := IHTMLDocument2(TWebBrowser(Sender).Document);
    sURL := Copy(Doc.activeElement.outerHTML, pos('href=',
      Doc.activeElement.outerHTML) + 5, length(Doc.activeElement.outerHTML) -
      pos('href=', Doc.activeElement.outerHTML) + 5);
    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('InternetExplorer.Application');
    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(WinHanlde);
      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
0
 
RickHalleCommented:
In your page you would use:
<a href="P1290414.jpg" target="_blank">PICTURE</a>

Rick
0
 
pistacerAuthor Commented:
uff, thar is, i mean, too complicated. i think, that f15iaf  is more near to that solution i need.
in onbeforenavigate i can catch width and height. now i know, that the pdisp is webbrowser object, wich is owning the properties width, height, document amd so.
now i need to detect, where in object document i have to read the values of the switchws toolbar, directories .... etc. that will be all.
0
 
RickHalleCommented:
Not waiting forever!
0
 
pistacerAuthor Commented:
i wrote, that your solution is too complicated for more reasons. one of them is that it requires to use the original IE. my browser is using the TWebBrowser on the application window and i wont put there the original IE windows too.

if you could give me adwice, where i could find required values in the pdisp parameter of OnBeforeNavigate method (pdisp is IExplorer object), i would be glad to send the points to you.
0
 
pistacerAuthor Commented:
i wrote, that your solution is too complicated for more reasons. one of them is that it requires to use the original IE. my browser is using the TWebBrowser on the application window and i wont put there the original IE windows too.

if you could give me adwice, where i could find required values in the pdisp parameter of OnBeforeNavigate method (pdisp is IExplorer object), i would be glad to send the points to you.
0
 
RickHalleCommented:
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.NewWindow2) and then uses automation to create the new instance while giving you access to the automation properties of it(MenuBar, AddressBar, etc.).

Rick
0
 
pistacerAuthor Commented:
i looked again at this piece of your code

begin
                    IE := CreateOleObject('InternetExplorer.Application');
                    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

and i found, that i can read that values thru

pdisp.menubar, pdisp.statusbar, etc, what means, the points will go to you.

sorry for waiting and that bullshit, i wrote above and twice! i will send the bonus to you!

sorry and thanks
0
 
pistacerAuthor Commented:
RickHalle , post here some comment please, i can not find link to accept you solution.

f15iaf, i will send  some points extra to you ...
0
 
RickHalleCommented:
"some comment here"

Rick
0
 
pistacerAuthor Commented:
no, no and no. do not know, what is with this question, but there are no links for accepting. i will send you the points extra.
0
 
pistacerAuthor Commented:
can not accept RickHalle's answer
0
 
RickHalleCommented:
Why are you deleting this?

Rick
0
 
pistacerAuthor Commented:
in this stupis page i can not find link to accept your answer, so when i want to send the points to you, i have to free them here by deleting this
0
 
RickHalleCommented:
Better to get a moderator to do it so it stays as a PAQ.

Rick
0
 
pistacerAuthor Commented:
that would be fine, how should i "get the moderator"?
0
 
RickHalleCommented:
I already left a message in community support.

Rick
0
 
pistacerAuthor Commented:
btw, there is a new qestion with points for you
0
 
kodiakbearCommented:
pistacer,
Scroll to the right and you will see the accept comment button. This Question is to large for the screen. If you prefer let me know which comment you want accepted as an answer and I will accept it for you. Leave a comment here or at
http://www.experts-exchange.com/jsp/qShow.jsp?ta=commspt&qid=20142121

kb
Community Support Moderator
Experts Exchange
0
 
pistacerAuthor Commented:
whoops! sorry sorry sorry.

i take all back

point from here are yours rickhalle
0
 
pistacerAuthor Commented:
and once more sorry!!!
0
 
kodiakbearCommented:
pistacer,
No need to be sorry, it is hard to navigate sometimes when the screen gets this large :)

kb
Community Support Moderator
Experts Exchange
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 14
  • 8
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now