Paul Jr
11-13-2003, 12:13 AM
I decided to try and get into some Java Script menu stuff, 'cause I haven't had much experience, and I thought it would be fun, and I've always wanted to. Well, I ran into a snag. This works almost fine, except that I want the submenu to go away either after a short while, or when you click on another part of the page.
<html><head><title>Test</title>
<script type="text/javascript">
function display(itemId) {
itemId = document.getElementById(itemId);
if (itemId.style.visibility == "hidden") {
itemId.style.visibility = "visible";
}else{
itemId.style.visibility = "hidden";
}
}
</script>
<style type="text/css">
#main {
width:420px;
border:3px ridge #F00;
border-bottom:transparent;
padding:10px;
margin:0px;
text-align:center;
}
a:link,a:visited {
height:25px;
background-color:#BDBDBD;
text-decoration:none;
padding:2px 10px 2px 10px;
margin:0px;
color:#626262;
border:1px solid #000;
}
a:hover {
background-color:#626262;
text-decoration:underline;
color:#BDBDBD;
}
a:active {
background-color:#FFF;
color:#000;
text-decoration:overline;
}
#sub {
padding:30px 0px 0px 0px;
visibility:hidden;
position:absolute;
top:53px;
left:111px;
border:3px ridge #F00;
border-top:transparent;
width:64px;
height:75px;
}
#sub a:link, #sub a:visited {
width:64px;
height:18px;
background-color:#626262;
text-decoration:none;
font-size:12px;
padding:2px;
margin:0px;
color:#BDBDBD;
border:1px solid #000;
}
</style>
</head>
<body>
<div id="main">
<a href="#">Home</a>
<a href="#" onMouseOver="display('sub');">About</a>
<a href="#">Links</a>
<a href="#">Gallery</a>
<a href="#">Contact</a>
</div>
<div id="sub" onUnFocus="document.this.style.visibility='hidden';">
<a href="#">Me</a>
<a href="#">Site</a>
</div>
</body>
</html>
I got the meat of the script working, after trying in IE6, so now I'm in the middle of tweaking the visuals in Moz 1.4, so it's probably not going to look exactly correct in either. Sorry.
Also, it appears you have to rollover the link twice to get the submenu to appear...:confused:
<html><head><title>Test</title>
<script type="text/javascript">
function display(itemId) {
itemId = document.getElementById(itemId);
if (itemId.style.visibility == "hidden") {
itemId.style.visibility = "visible";
}else{
itemId.style.visibility = "hidden";
}
}
</script>
<style type="text/css">
#main {
width:420px;
border:3px ridge #F00;
border-bottom:transparent;
padding:10px;
margin:0px;
text-align:center;
}
a:link,a:visited {
height:25px;
background-color:#BDBDBD;
text-decoration:none;
padding:2px 10px 2px 10px;
margin:0px;
color:#626262;
border:1px solid #000;
}
a:hover {
background-color:#626262;
text-decoration:underline;
color:#BDBDBD;
}
a:active {
background-color:#FFF;
color:#000;
text-decoration:overline;
}
#sub {
padding:30px 0px 0px 0px;
visibility:hidden;
position:absolute;
top:53px;
left:111px;
border:3px ridge #F00;
border-top:transparent;
width:64px;
height:75px;
}
#sub a:link, #sub a:visited {
width:64px;
height:18px;
background-color:#626262;
text-decoration:none;
font-size:12px;
padding:2px;
margin:0px;
color:#BDBDBD;
border:1px solid #000;
}
</style>
</head>
<body>
<div id="main">
<a href="#">Home</a>
<a href="#" onMouseOver="display('sub');">About</a>
<a href="#">Links</a>
<a href="#">Gallery</a>
<a href="#">Contact</a>
</div>
<div id="sub" onUnFocus="document.this.style.visibility='hidden';">
<a href="#">Me</a>
<a href="#">Site</a>
</div>
</body>
</html>
I got the meat of the script working, after trying in IE6, so now I'm in the middle of tweaking the visuals in Moz 1.4, so it's probably not going to look exactly correct in either. Sorry.
Also, it appears you have to rollover the link twice to get the submenu to appear...:confused: