Popup Window Location

  • Thread starter Thread starter John Kotuby
  • Start date Start date
J

John Kotuby

Hi all,
How do I get a popup window to appear within the boundaries of the parent
window?
I am using JavaScript Window.Open and setting top=1 and left=1 but that
causes it to show up in the top left corner of the screen itself. Setting
the location attribute to either 1 or 0 doesn't seem to make a difference
either.

An example:
window.open("popwin.aspx","popwin","title=hide,toolbar=0,location=0,status=0,menubar=0,scrollbars=1,resizable=1,
width=550px,height=600px,top=1,left=1");

Any help would be appreciated.
 
How do I get a popup window to appear within the boundaries of the parent
window?

By setting the top and left name-value pairs of the third argument in the
window.open() method...
I am using JavaScript Window.Open and setting top=1 and left=1 but that
causes it to show up in the top left corner of the screen itself.

That's correct - top=1 means position the top of the new window at pixel
number 1 of the screen...
Setting the location attribute to either 1 or 0 doesn't seem to make a
difference either.

It wouldn't - location specifies the presence of the location bar, nothing
to do with the position of the window on the screen...
Any help would be appreciated.

If you want the window to open at a specific screen location, you'll need to
tell JavaScript what that location is...

E.g. if you want it to open in the centre of the screen, you'd need to
specify the following name-value pairs:

top=(screen.height-height)/2;
left=(screen.width-width)/2;
 
Thanks Mark,

I thought that the Top and Left were in relation to the location of the
Window.Opener itself and not the screen.
I appreciate the clarification.

Happy New Year... John
 
Back
Top