setTimeout or setInterval

Discussion in 'JavaScript' started by Navarone, Oct 30, 2007.

  1. #1
    On the web site I am building http://dev-rico-v2.virtualhorizons.com/
    I would like the menu in the first button "Designer Series" to open shortly after the page loads be visible for about 2 seconds then close. Would I use the setTimeout() or setInterval() function to do this and what would the script look like? :)
     
    Navarone, Oct 30, 2007 IP
  2. Navarone

    Navarone Guest

    Messages:
    59
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I tried setInterval and the menu shows up but I can't close the menu after I clear the Interval.

    
    <script type="text/javascript">
    
    setInterval ( "showMenu()", 1000 );
    
    function showMenu()
    {
      // (do something here)   
      Show('designer_menu') 
    }
    clearInterval ("hideMenu");
    
    function hideMenu()
    {
    	Hide('designer_menu')
    	
    }
    
    </script>
    
    
    Code (markup):
     
    Navarone, Oct 30, 2007 IP
  3. Navarone

    Navarone Guest

    Messages:
    59
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    ok, I figured it out
    
    	//call showMenu function when page loads	
    	  setTimeout ("showMenu()",1000);
    		
    	//show menu
    	function showMenu()	{	   
    	  Show('designer_menu');
    	   setTimeout ( "hideMenu()", 2000 );	   
    	}
    	
    	//hide menu
    	function hideMenu()	{	
    	   Hide('designer_menu');		   
    	}
    
    Code (markup):
     
    Navarone, Oct 30, 2007 IP