setTimeout is not working online with Firefox

Discussion in 'JavaScript' started by media12, Feb 28, 2009.

  1. #1
    When I run this script on my localhost, it works great with both IE7 and Firefox3. But when I've uploaded it to my site, it only works with IE, and not Firefox.

    The script should just hide the DIV after 2 seconds.

    <html>
    	<head>
    
    		<SCRIPT language="JavaScript">
    		<!--
    
    		function Hidenn() {
    			setTimeout("HideMenus()",2000);
    		}
    
    		function HideMenus() {
    			menuss1.style.visibility = 'hidden';
    		}
    
    		//-->
    		</SCRIPT> 
    
    	</head>
    
    	<body>
    
    		<a href="#" onclick="Hidenn();">Link 1 </a>  
    
    		<div id="menuss1">hddhdhdhd</div>
    
    	</body>
    </html>
    Code (markup):
    Any suggestions on how I could fix this?
     
    media12, Feb 28, 2009 IP
  2. dimitar christoff

    dimitar christoff Active Member

    Messages:
    882
    Likes Received:
    62
    Best Answers:
    0
    Trophy Points:
    90
    #2
    you need to stop the propagation of the onclick event - return false or whatever.

    and menuss1.style.visibility -> change to document.getElementById("menuss1").style.visibility.
     
    dimitar christoff, Feb 28, 2009 IP
  3. ads2help

    ads2help Peon

    Messages:
    2,142
    Likes Received:
    67
    Best Answers:
    1
    Trophy Points:
    0
    #3
    The only problem I see is

    should be

    or

     
    ads2help, Feb 28, 2009 IP
  4. media12

    media12 Peon

    Messages:
    33
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    That works perfectly! Many thanks to you guys!
     
    media12, Mar 1, 2009 IP