Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / December 2007

Tip: Looking for answers? Try searching our database.

Popup Window Location

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
John Kotuby - 29 Dec 2007 06:42 GMT
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.
Mark Rae [MVP] - 29 Dec 2007 12:13 GMT
> 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;

Signature

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

John Kotuby - 31 Dec 2007 15:03 GMT
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

>> How do I get a popup window to appear within the boundaries of the parent
>> window?
[quoted text clipped - 24 lines]
> top=(screen.height-height)/2;
> left=(screen.width-width)/2;

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.