Jump to content
  • Advertisement
Sign in to follow this  
Supaflyfrank

[web] Non Disappearing Div

This topic is 4857 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Some reason practicing for my menu on a seperate HTML file I cant get this div tag to go invisable using javascript i get this error Error: theMenu has no properties Source File: Line: 25 but if I changed the line: <div id="menu1" onmouseout="hide('menu1');" onmouseover="show('menu1');"> to: <div id="menu1" onmouseout="hide('menu1');"> it works like a charm. What I really want to do is for the menu to disappear when I click it. But i dont understand why it isnt working for me now.
[source lang = "javascript"]
<html>
<head>
<title>Business</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<script type = "text/javascript">



(document.getElementById ? DOMCapable = true : DOMCapable = false);
function hide(menuName)
{
if (DOMCapable)
{
var theMenu = document.getElementById(menuName);
theMenu.style.visibility = 'hidden';
}
}

function show(menuName)
{
	if (DOMCapable)
	{
	var theMenu = document.getElementById(menuName+"choices");
	theMenu.style.visibility = 'visible';
	}
}





</script>
</head>
<body bgcolor="#A4B4E0" leftmargin="0" topmargin="0" marginwidth="0" 

marginheight="0">




<div id="menu1"  
onmouseout="hide('menu1');" onmouseover="show('menu1');">
 <img src = "BusinessContents.png">
</div>


</script>
</body>
</html>


[Edited by - Supaflyfrank on December 2, 2005 4:23:15 PM]

Share this post


Link to post
Share on other sites
Advertisement
I think your problem is here :
var theMenu = document.getElementById(menuName+"choices");
in the show function.
There is no element with the id "menu1choices" so the getElementById returns null, and that's why you get the error. Remove the +"choices" and things should work ok.
Steele.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!