This works :

<script type="text/javascript">
function test(){
$('mydiv').hide();
var vp_dims = document.viewport.getDimensions();
var vp_scrolloffset = document.viewport.getScrollOffsets();
var mydivdims = $('mydiv').getDimensions();
$('mydiv').setStyle({ top:''+Math.abs((vp_dims.height-
mydivdims.height)/2+vp_scrolloffset.top)+'px', left:''+Math.abs
((vp_dims.width-mydivdims.width)/2+vp_scrolloffset.left)+'px' });
$('mydiv').show();
}

document.observe('dom:loaded', function() {
        Event.observe(window, 'resize', test, true);
        Event.observe(window, 'scroll', test, true);
        test();
});
</script>
...
and then :
...
<div id="mydiv" style="position:absolute; width:500px; height:250px;
color:#F00; background-color:#9999FF; display:none;"></div>


you have to declare the style propertes of "mydiv" when you create it
dynamically.

It works a bit fine on IE & FF but "flicky" when you scroll.
The div.hide() / div.show() i added in the function are not efficient
enough to prevent it...


Tell me if this is what you wanted.

Best regards.
Michel L'HUILLIER
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to