Popup Window Location

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.
 
M

Mark Rae [MVP]

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;
 
J

John Kotuby

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,709
Latest member
AustinMudi

Latest Threads

Top