Jeztah wrote:
> Mornign guys ..
> I am very well being really thick here but i was wondering how to
> center a window vertically to the viewport (i.e if the user is
> scrolled down the page a bit to still be in the center) ..
> Now the really annoying thing is i've done it before and put it into a
> nice function but i cant for the life of me find it on my mess that is
> a server !!!

You should determine the offset the document have been scrolled down,
the total height of the viewport, and the height of your window.

var offsets =  document.viewport.getScrollOffsets();
var viewPortDims =  document.viewport.getDimensions();
var windowDims = $(your_window_here).getDimensions();
var windowOffsets = {position: 'absolute'}; = + (viewPortDims.height - windowDims.height) / 2;
//if you want to center also horizontally:
windowOffsets.left =
     offsets.left + (viewPortDims.width - windowDims.width) / 2;

//Or use Scriptaculous to move windows
var effect = new Effect.Move(your_window_here,
     { x:, y: windowOffsets.left, mode: 'absolute' }

Of course your window have to be a child of body, or it might be 
posisioned to any relatively positioned of its ancestors!

Should work, but not tested

You received this message because you are subscribed to the Google Groups 
"Prototype &" group.
To post to this group, send email to
To unsubscribe from this group, send email to
For more options, visit this group at

Reply via email to