LiveWire Network Peer Answers Peer Support Teen Forums Tech Forums College Forums 476 users online 225254 members 776 active today Advertise Here Sign In
TeenCollegeTechPhotos | Quizzes | LiveSecret | Memberlist | Dictionary | News | FAQ
Member Spotlight
Mhairi
Favs: films ~ anything food ~ icecream and ca...
Mood: Carefree
You have 1 new message.
Emergency Help
Until you sign up you can't do much. Yes, it's free.

Sign Up Now
Membername:
Password:
Already have an account?
Invite Friends
Active Members
Groups
Contests
Moderators
5 online / 23 MPM
Christmas!
Fresh Topics
  LiveWire / Technical Forums / Web Design & Search Engine Optimization / Adding Reply

Adding Reply
Archived Topic: It will not be bumped to the top of the forum.
Topic javascript
Membername   Not a member? Sign Up Free (takes 20 seconds)
Password   Forgotten your password?
Post

Font:   Size:   Color:

FAQ Keyword Search:
Post Options
Favorites Manager
Notify me of new replies to this topic by email
Notify me of new replies to this topic by private message
Original Post
Echo one Posted at 8:52 pm on Jan. 12, 2008
hey, let's get this out of the way. I do not in any way consider myself good at javascript. As a web designer it has been my weakness. I don't know why, it just is. I can write php, but javascript gives me a headache.

alright, so this is a basic list-based DHTML drop down navigation menu. the old script I had was rather static in it's methods (it used names rather than dealing with the concept itself)
in other words it was built for a specific instance.

I'm getting to the point where I'm tired of it, so I'm trying to move to a dynamic script that will build whatever I want it to dynamically. so I'm trying to use nodes.

the problem is apparently not in the syntax (I'm not getting those little yellow error messages in the corner) it's somewhere in the script itself that is not applying itself to what I want it to. ie, nothing happens onMouseOver.

Code:
<script type='text/JavaScript'>
function list() {
  if (document.getElementsByTagName) {
      node="document.getElementsByTagName('LI')";
      listNode = "document.getElementsByTagName('UL')";
      node.onMouseOver = "node.childNodes.style.display = 'block'";
      }
      node.onMouseOut = "node.childNodes.style.display = 'none'; if (listNode.class == 'sub') { listNode.style.display = 'none'}";
      }
      if (node.childNodes.style.display == 'block') {
         node.style.display = 'block';
      }
  }
  else {
      alert("your browser does not support javascript. Either you have it turned off or do not have it, this page may not load correctly and you may not be able to access certain parts of the site.")
  }
}    
body.onLoad = list();
</script>

alright, so can anyone tell me why it's not doing anything on li.onMouseOver?

Replies
Echo one Posted at 8:22 am on Jan. 21, 2008
that's the code that I wrote, that's the one that's not working. Do you see anything wrong with it?
pleaseremove Posted at 3:05 am on Jan. 21, 2008
Quote: from Echo one at 7:04 am on Jan. 21, 2008

Code:
* html ul li { float: left; }
* html ul li a { height: 1%; }
ul {
margin: 0;
        padding-right: 15px;
   list-style: none;
}
ul li {
        position: relative;
        font-color: #0000ff;
        list-style: none;
        background-color:blue;
}
li ul {
        display:none;
        list-style:none;
position: absolute;
padding: 20px;
top: 45px;
left: 0px;
        width: 60px;
        font-color: #0000ff;
}
li:hover ul {
        display:block;
}
li a:hover ul {
        display:block;
}
li ul:hover, li a ul:hover {
        display:block;
}

that's basically what I have (without putting in all of the rest of the just aesthetic things to change the menu.

It works by using the display element in css. You will notice that some points use display:none and then later in the same parts hover it uses display:block. So basically your menu exists in full on your page and then it uses the css hover element to make certain parts of it show-up.

Echo one Posted at 11:04 pm on Jan. 20, 2008
Code:
* html ul li { float: left; }
* html ul li a { height: 1%; }
ul {
margin: 0;
       padding-right: 15px;
  list-style: none;
}
ul li {
       position: relative;
       font-color: #0000ff;
       list-style: none;
       background-color:blue;
}
li ul {
       display:none;
       list-style:none;
position: absolute;
padding: 20px;
top: 45px;
left: 0px;
       width: 60px;
       font-color: #0000ff;
}
li:hover ul {
       display:block;
}
li a:hover ul {
       display:block;
}
li ul:hover, li a ul:hover {
       display:block;
}

that's basically what I have (without putting in all of the rest of the just aesthetic things to change the menu.
Echo one Posted at 11:01 pm on Jan. 20, 2008
it works amazingly. I just can't figure out from their source how they did it. I know it's pathetic. Coding has never come all that easily to me.
PiXiE Posted at 10:43 pm on Jan. 20, 2008
Hmm. This works on my Firefox and IE7: http://www.grc.com/menu2/invitro.htm

Echo one Posted at 8:04 pm on Jan. 20, 2008
Quote: from PiXiE at 2:15 pm on Jan. 20, 2008

Check out this article: http://alistapart.com/articles/hybrid

lol I actually tried that one once. Just I'm trying to learn how to develop my own. I just need to know the specific css way to make something pop out on a hover. It's not working in my browser for some reason, and I can't test it in others. I'm trying to make it all css since, as Pleaseremove pointed out, javascript can be turned off, and that is my main navigation.

PiXiE Posted at 2:15 pm on Jan. 20, 2008
Check out this article: http://alistapart.com/articles/hybrid
Echo one Posted at 2:09 pm on Jan. 20, 2008
Quote: from pleaseremove at 6:31 am on Jan. 20, 2008

Quote: from Echo one at 12:55 am on Jan. 20, 2008

Quote: from pleaseremove at 6:11 am on Jan. 15, 2008

OK, I'm not actually sure what you want your code to do here. Is this just a drop-down menu?

  Anyway, if it is you should be doing this with CSS, the last thing you want to do is make the core way people navigate with your site based on something that could be turned off.


 

 it's a mix of css and javascript. I'm aware that that poses problems but I'm not sure there's a way to do this without some javascript involved. At best I could store a lot of the info in the :hover attribute, but at the very least to my knowledge the display attribute has to be changed with javascript since the act of displaying involves the mouseover of a different object.  

 keep in mind that I have a script that works, but it deals only with specific instances ie. this is what happens when this. This one, I'm trying to make it apply to any instance of a drop down or otherwise onMouseOver display menu by saying that anyLi.onMouseOver = display sublist if one exists.


Sounds like you want to look into something like this:

http://www.tjkdesign.com/articles/keyboard_friendly_dropdown_menu/default.asp


that would be great, except that site had no information on how to do a pure css dropdown menu. I've heard of them, and attempted them. But it comes down to needing to be able to use ul li:hover and idk if other browsers support it, but my ie for some reason does not.

pleaseremove Posted at 6:31 am on Jan. 20, 2008
Quote: from Echo one at 12:55 am on Jan. 20, 2008

Quote: from pleaseremove at 6:11 am on Jan. 15, 2008

OK, I'm not actually sure what you want your code to do here. Is this just a drop-down menu?  

 Anyway, if it is you should be doing this with CSS, the last thing you want to do is make the core way people navigate with your site based on something that could be turned off.


it's a mix of css and javascript. I'm aware that that poses problems but I'm not sure there's a way to do this without some javascript involved. At best I could store a lot of the info in the :hover attribute, but at the very least to my knowledge the display attribute has to be changed with javascript since the act of displaying involves the mouseover of a different object.

keep in mind that I have a script that works, but it deals only with specific instances ie. this is what happens when this. This one, I'm trying to make it apply to any instance of a drop down or otherwise onMouseOver display menu by saying that anyLi.onMouseOver = display sublist if one exists.


Sounds like you want to look into something like this:

http://www.tjkdesign.com/articles/keyboard_friendly_dropdown_menu/default.asp

Echo one Posted at 4:55 pm on Jan. 19, 2008
Quote: from pleaseremove at 6:11 am on Jan. 15, 2008

OK, I'm not actually sure what you want your code to do here. Is this just a drop-down menu?

Anyway, if it is you should be doing this with CSS, the last thing you want to do is make the core way people navigate with your site based on something that could be turned off.


it's a mix of css and javascript. I'm aware that that poses problems but I'm not sure there's a way to do this without some javascript involved. At best I could store a lot of the info in the :hover attribute, but at the very least to my knowledge the display attribute has to be changed with javascript since the act of displaying involves the mouseover of a different object.

keep in mind that I have a script that works, but it deals only with specific instances ie. this is what happens when this. This one, I'm trying to make it apply to any instance of a drop down or otherwise onMouseOver display menu by saying that anyLi.onMouseOver = display sublist if one exists.

pleaseremove Posted at 6:11 am on Jan. 15, 2008
OK, I'm not actually sure what you want your code to do here. Is this just a drop-down menu?

Anyway, if it is you should be doing this with CSS, the last thing you want to do is make the core way people navigate with your site based on something that could be turned off.

Echo one Posted at 5:55 pm on Jan. 13, 2008
that doesn't really matter does it?
Echo one Posted at 5:55 pm on Jan. 13, 2008
xhtml, and it's been awhile, remind me what dtd is.
rand0mguy Posted at 5:13 pm on Jan. 13, 2008
are you using xhtml or html.. and waht DTD
All 14 previous replies displayed.