Web Hosting - Wordpress Theme - Wordpress Themes - Deaf Topics - Find jobs

PDA

View Full Version : setTimeout is not working online with Firefox


media12
Feb 28th 2009, 7:28 am
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>

Any suggestions on how I could fix this?

dimitar christoff
Feb 28th 2009, 2:58 pm
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.

ads2help
Feb 28th 2009, 11:28 pm
The only problem I see is

menuss1.style.visibility

should be

document.getElementById("menuss1").style.visibility

or


var menuss1 = document.getElementById("menuss1");
menuss1.style.visibility = 'xxxx'

media12
Mar 1st 2009, 2:08 pm
That works perfectly! Many thanks to you guys!