Click to See Complete Forum and Search --> : dynamically position a window


Webskater
03-19-2003, 10:04 AM
I am opening a window to display a calendar so users can select a date and it populates a field on the (underlying) page. How can I open the calendar window so it is always near the link that called it but not obscuring the link? Thanks for any help. (On some pages the link opening the calendar window might be at the top left of the page - on other pages it is at the bottom right of the page - sometimes it is in the middle. I need to make sure the calendar window always opens so it does not obscure the link that opened it.)

DaiWelsh
03-19-2003, 10:17 AM
Youi should be able to use the event object in the onClick handler to find out where the mouse was clicked, but getting from that to where to position a window is not as easy as it sounds, since the user may have different sizes of screen. The screen object can be used to find the height and width of the screen and you could then for example put the window to the right if the click point was less than half way across the screen and below if the click point was less than half way down the screen. It wont be perfect but it should get you though most situations.

khalidali63
03-19-2003, 11:39 AM
Here take a look at this link.It positiones a popup window in the middle of the screen.
The underlying code should be fairly simple to use for your needs.

http://68.145.35.86/skills/javascripts/CentralizedPopupWindow.html

Cheers

Khalid