Click to See Complete Forum and Search --> : beginner question
beowulf405
11-11-2003, 06:41 PM
I've been trying to get dropdown menus to work in netscape. In order to do this I have been trying to set the visible property in a java script.
element.style.visibility = "visible" where element is defined in a style sheet and used as an id.
when used with the onmouseover property it works fine in IE. Netscape, however, will not set the property. How do I get netscape to set a property the visibility property?
PeOfEo
11-11-2003, 06:49 PM
Heh, I was just dealing with this myself.
http://forums.webdeveloper.com/showthread.php?s=&threadid=21014&pagenumber=2
Ill copy my java script for you
function showmenu(elmnt)
{
document.getElementById(elmnt).style.visibility = "visible";
}
function hidemenu(elmnt)
{
document.getElementById(elmnt).style.visibility = "hidden";
}
the site it is on is http://knights.europe.webmatrixhosting.net/wfrp/index.html
kudos to pyro and toicontien for showing me that document.getelementbyid is the universal method.
beowulf405
11-12-2003, 12:56 PM
Maybe I'm doing something else wrong because I can't get that to work in either IE or NS. Here is the code that I have:
<html>
<head>
<style>
.menu {background-color: "#E8AE00"; color: black; width: 8em; text-align: center}
#psub {
position: absolute; left: "15em"; top: "1em";
font: "bold"; }
</style>
<script type="text/javascript">
function testr(elmnt){
document.getElementById(elmnt).style.visibility = "visible";
}
function initit(tes){
var qrt = document.getElementById(tes);
qrt.style.visibility = "hidden";
}
window.onload = function(){
initit("psub");
}
</script>
</head>
<body bgcolor="#E8AE00">
<div>
<ul>
<li onmouseover="testr(psub);"><p> Infromation </p></li>
<div id="psub">
<ul class="submenu">
<li><a href="http://google.com">Google</li>
<li ><a href="http://staff.com" >Staff</li>
<li ><a href="http://officials.com" >Officials</li>
</ul>
<div>
</ul>
</div>
</body>
</html>
With this code IE will call the function but ignore the visible statement. Netscape will not even call it. If I replace visible statement with psub.style.visibility = "visible" ie will work.
What am I doing Wrong????
:confused:
Change:
onmouseover="testr(psub);"
to:
onmouseover="testr('psub');"
spufi
11-12-2003, 02:06 PM
<style type="text/css">
<!--
body {#E8AE00; }
.menu {background-color: #E8AE00; color: black; width: 8em; text-align: center;}
#psub {
position: absolute; left: 15em; top: 1em;
font: bold; }
-->
</style>
That's what your CSS should look like.
beowulf405
11-13-2003, 02:15 PM
GREAT -- Thanks -- it worked
I added an onmouseout to the div statement which works but turns the menu off too quick. I thought the onmouseout would activate when it left the Div area. Isn't this true?
No, you must explicitly set an onmouseout...