Popup Window Location

Popup Window Location

am 29.12.2007 07:42:19 von 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,loc ation=0,status=0,menubar=0,scrollbars=1,resizable=1,
width=550px,height=600px,top=1,left=1");

Any help would be appreciated.

Re: Popup Window Location

am 29.12.2007 13:13:06 von mark

"John Kotuby" wrote in message
news:eLFlQWeSIHA.3516@TK2MSFTNGP02.phx.gbl...

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


--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Re: Popup Window Location

am 31.12.2007 16:03:03 von 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

"Mark Rae [MVP]" wrote in message
news:%23A0yeQhSIHA.280@TK2MSFTNGP03.phx.gbl...
> "John Kotuby" wrote in message
> news:eLFlQWeSIHA.3516@TK2MSFTNGP02.phx.gbl...
>
>> 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;
>
>
> --
> Mark Rae
> ASP.NET MVP
> http://www.markrae.net