Solved

twebbrowser newwin parameters

Posted on 2001-06-08
26
510 Views
Last Modified: 2010-04-06
------------------------------------------------
<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
Comment
Question by:pistacer
  • 14
  • 8
  • 2
  • +1
26 Comments
 
LVL 3

Expert Comment

by:f15iaf
ID: 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;
0
 

Author Comment

by:pistacer
ID: 6167314
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
 
LVL 3

Expert Comment

by:f15iaf
ID: 6167381
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
 

Author Comment

by:pistacer
ID: 6167793
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
 
LVL 2

Accepted Solution

by:
RickHalle earned 125 total points
ID: 6168960
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
 
LVL 2

Expert Comment

by:RickHalle
ID: 6168968
In your page you would use:
<a href="P1290414.jpg" target="_blank">PICTURE</a>

Rick
0
 

Author Comment

by:pistacer
ID: 6175947
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
 
LVL 2

Expert Comment

by:RickHalle
ID: 6223632
Not waiting forever!
0
 

Author Comment

by:pistacer
ID: 6223738
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
 

Author Comment

by:pistacer
ID: 6223938
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
 
LVL 2

Expert Comment

by:RickHalle
ID: 6223941
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
 

Author Comment

by:pistacer
ID: 6223952
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
 

Author Comment

by:pistacer
ID: 6223992
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
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
LVL 2

Expert Comment

by:RickHalle
ID: 6224105
"some comment here"

Rick
0
 

Author Comment

by:pistacer
ID: 6224237
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
 

Author Comment

by:pistacer
ID: 6224241
can not accept RickHalle's answer
0
 
LVL 2

Expert Comment

by:RickHalle
ID: 6228848
Why are you deleting this?

Rick
0
 

Author Comment

by:pistacer
ID: 6230173
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
 
LVL 2

Expert Comment

by:RickHalle
ID: 6230196
Better to get a moderator to do it so it stays as a PAQ.

Rick
0
 

Author Comment

by:pistacer
ID: 6230229
that would be fine, how should i "get the moderator"?
0
 
LVL 2

Expert Comment

by:RickHalle
ID: 6230255
I already left a message in community support.

Rick
0
 

Author Comment

by:pistacer
ID: 6230274
btw, there is a new qestion with points for you
0
 
LVL 1

Expert Comment

by:kodiakbear
ID: 6231391
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
 

Author Comment

by:pistacer
ID: 6231898
whoops! sorry sorry sorry.

i take all back

point from here are yours rickhalle
0
 

Author Comment

by:pistacer
ID: 6231906
and once more sorry!!!
0
 
LVL 1

Expert Comment

by:kodiakbear
ID: 6232073
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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now