Mootools Multibox - delay opening

Discussion in 'JavaScript' started by alterity, Dec 13, 2010.

  1. #1
    This is my first time here. Hello!

    So I have configured a mootools multibox to open when the page has loaded. Like so:

    
    <script type='text/javascript'>
    	var box11 ={};
    	window.addEvent('domready', function()
    	{
    		box11 = new MultiBox('mb', {descClassName: 'multiBoxDesc', useOverlay: true, openFromLink: false});		
    		box11.open($('mb11'))
    	});						 
    </script>
    
    Code (markup):
    Now I am trying with all my might to delay the box from opening until about 8 seconds have passed.

    There is a [waitDuration] option but this doesn't delay the appearance of the box. Instead it delays the box's content from appearing. This is obviously not my solution.

    Can anyone help me figure out a way to delay the box from opening about 8 seconds?

    Many thanks.
     
    alterity, Dec 13, 2010 IP
  2. shofstetter

    shofstetter Well-Known Member

    Messages:
    178
    Likes Received:
    7
    Best Answers:
    1
    Trophy Points:
    120
    #2
    you could place your code inside of a function and call it using:

    setTimeout ( expression, timeout );
     
    shofstetter, Dec 13, 2010 IP
  3. alterity

    alterity Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    The solution did have something to do with setTimeout, using it to delay the opening. So the page loads, 15 seconds pass, the multibox appears.

    
    <script type="text/javascript">
         var box = {};
         window.addEvent('domready', function(){
            box = new MultiBox('mb', {showNumbers: false, showControls: true, descClassName: 'multiBoxDesc', useOverlay: true});
    	window.setTimeout(function(){box.open($('mb'))},'15000');			
         });
    </script>
    
    Code (markup):
    Thanks for the assist.
     
    alterity, Dec 14, 2010 IP
  4. shofstetter

    shofstetter Well-Known Member

    Messages:
    178
    Likes Received:
    7
    Best Answers:
    1
    Trophy Points:
    120
    #4
    just change 15000 to 8000. milliseconds = seconds * 1000

    
    <script type="text/javascript">
         var box = {};
         window.addEvent('domready', function(){
            box = new MultiBox('mb', {showNumbers: false, showControls: true, descClassName: 'multiBoxDesc', useOverlay: true});
    	window.setTimeout(function(){box.open($('mb'))},'8000');			
         });
    </script>
    
    Code (markup):
     
    shofstetter, Dec 14, 2010 IP