PDA

View Full Version : Drop down menu not working in IE



alexjewell
03-25-2006, 02:00 PM
I wrote a drop down menu thing, with JavaScript and CSS, that is SUPPOSED to work in IE, as well as Mozilla...
Now, the issue is: it's not working in Mozilla.
I can't seem to figure out why.
www.flamehtmlstudios.com/amanda/beta/ is the html
www.flamehtmlstudios.com/amanda/beta/main.css is the css
www.flamehtmlstudios.com/amanda/beta/nav.js is the javascript
help?!

ps - another question: is a script to use to get IE to display the hovers that don't work in it? For example, something like p:hover{border-color: black;} would work in firefox, but not IE. How would I get it to work in IE, too?

jscheuer1
03-25-2006, 02:39 PM
In Mozilla document.all is undefined or false, so everything here (in red) will not fire:


<!--//--><![CDATA[//><!--
startList = function() {
if (document.all&&document.getElementById) {
navRoot = document.getElementById("nav");
for (i=0; i<navRoot.childNodes.length; i++) {
node = navRoot.childNodes[i];
if (node.nodeName=="LI") {
node.onmouseover=function() {
this.className+=" over";
}
node.onmouseout=function() {
this.className=this.className.replace(" over", "");
}
}
}
}
}
window.onload=startList;

//--><!]]>

Also, the green parts are not needed in an external script and could possibly cause problems in some browsers, though in this particular case I doubt it, safest thing is to get rid of them.

Try getting rid of the green and changing this:


if (document.all&&document.getElementById) {

to this:


if (document.getElementById) {

Without testing, it looks like that should at least get it doing something in Mozilla, let us know.

alexjewell
03-26-2006, 03:35 AM
Ooops...I meant it's not working in IE...
It was working in Mozilla...
Still is in Mozilla...
Still is NOT in IE...

jscheuer1
03-26-2006, 04:03 AM
Ooops...I meant it's not working in IE...
It was working in Mozilla...
Still is in Mozilla...
Still is NOT in Mozilla...

Huh? Anyways, after looking at your css, which I skipped before, it (the css) alone can power this menu in Mozilla and Opera. The javascript is only for IE, because IE will not do :hover styles for anything other than an anchor link element. So, assuming the script is otherwise sound, I'd put back the document.all part and even add to it:


if (document.all&&document.getElementById&&(!window.opera)) {

However here:


this.className=this.className.replace(" over", "");

We have a syntax error, it should be:


this.className=this.className.replace(/ over/, "");

If the code is otherwise selecting the correct elements to apply these events to and the .over class is appropriate, that should do it.

jscheuer1
03-26-2006, 04:47 AM
I tried it out in a local demo, and I'd say go back to the drawing board. Where did you get this code in the first place?

alexjewell
04-05-2006, 12:07 AM
I wrote it myself.
Is it possible you could hook me up with a javascript code that would work?
Thanks so much for even taking the time to work on it yourself before, too, it means a lot.