views:

102

answers:

1

Hi, could someone maybe give me a small hint on how to do this with mootools.

Basically i have a div like

<div id="center-panel" style="height: 200px; width 200px; background: green;"></div>

i basically want this div tag hidden by default, and then once the user has been on the website for like two minutes i want the div tag to display>

+1  A: 

In an onload handler for your site, use setTimeout() to show the div after 2 minutes:

function showDiv(){
    $('center-panel').setStyle('display', 'block');
};
setTimeout(showDiv, 60 * 1000 * 2);

You can see it in action here with a 2 second delay rather than 2 minutes.

Pat
thankyou so much for that !!!! how could i add some affects so that the div overlays everything else and kind of slides up to be displayed
To get it to overlay everything, set it to `position: absolute` with a `z-index` value higher than all your other elements. You can then morph its `left` and `top` values to move it around. The morph docs can get you started on that part: http://mootools.net/docs/core/Fx/Fx.Morph
Pat
mootools abstracts `setTimeout` to `function.delay(nnn)` - I wouldn't use a named function either. check out http://jsfiddle.net/BTbuQ/1/ - it should really be refactored to be a reusable pattern but this is close, ensures compatibility with jquery etc and is more mooish
Dimitar Christoff
here's an example via an Element prototype: http://jsfiddle.net/BTbuQ/2/ and a fade in effect
Dimitar Christoff