By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,677 Members | 1,076 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,677 IT Pros & Developers. It's quick & easy.

Question Concerning a Java Script Menu

Stang02GT
Expert 100+
P: 1,208
I posted a question in the HTML/CSS Forum but i have not received an answer. I have a menu that I am using from http://www.javascriptkit.com .

The exact url to the menu i am using is :

http://www.javascriptkit.com/script/script2/csstopmenu.shtml

My problem is that the page i placed the menu on, everything on that page is centered and stays underneath the page heading. I have having trouble positioning my menu within the same area as the rest of the page. I'm not sure if I can do this with JavaScript or if this is strictly an HTML/CSS Issue.


Any help is greatly appreciated.


Here is the javascript that the menu uses.

Expand|Select|Wrap|Line Numbers
  1. var cssmenuids=["cssmenu1"] //Enter id(s) of CSS Horizontal UL menus, separated by commas
  2. var csssubmenuoffset=-1 //Offset of submenus from main menu. Default is 0 pixels.
  3.  
  4. function createcssmenu2(){
  5. for (var i=0; i<cssmenuids.length; i++){
  6.   var ultags=document.getElementById(cssmenuids[i]).getElementsByTagName("ul")
  7.     for (var t=0; t<ultags.length; t++){
  8.             ultags[t].style.top=ultags[t].parentNode.offsetHeight+csssubmenuoffset+"px"
  9.         var spanref=document.createElement("span")
  10.             spanref.className="arrowdiv"
  11.             spanref.innerHTML="&nbsp;&nbsp;&nbsp;&nbsp;"
  12.             ultags[t].parentNode.getElementsByTagName("a")[0].appendChild(spanref)
  13.         ultags[t].parentNode.onmouseover=function(){
  14.                     this.style.zIndex=100
  15.         this.getElementsByTagName("ul")[0].style.visibility="visible"
  16.                     this.getElementsByTagName("ul")[0].style.zIndex=0
  17.         }
  18.         ultags[t].parentNode.onmouseout=function(){
  19.                     this.style.zIndex=0
  20.                     this.getElementsByTagName("ul")[0].style.visibility="hidden"
  21.                     this.getElementsByTagName("ul")[0].style.zIndex=100
  22.  
  23.         }
  24.     }
  25.   }
  26. }
  27.  
  28. if (window.addEventListener)
  29. window.addEventListener("load", createcssmenu2, false)
  30. else if (window.attachEvent)
  31. window.attachEvent("onload", createcssmenu2)
Jan 15 '08 #1
Share this Question
Share on Google+
8 Replies


Stang02GT
Expert 100+
P: 1,208
here is the link to the post in the HTML/CSS form also in case anyone would like to see it as well.


http://www.thescripts.com/forum/thread757392.html
Jan 15 '08 #2

acoder
Expert Mod 15k+
P: 16,027
You can set it with JavaScript, but I think you'd be better off setting it with CSS so that it's correctly positioned whilst loading and not after loading.
Jan 16 '08 #3

Stang02GT
Expert 100+
P: 1,208
You can set it with JavaScript, but I think you'd be better off setting it with CSS so that it's correctly positioned whilst loading and not after loading.

Ok, what do you suggest is the best way to do that?
Jan 16 '08 #4

acoder
Expert Mod 15k+
P: 16,027
Ok, what do you suggest is the best way to do that?
That's better left to the thread in the HTML forum where I see that you now have a response. You may need to post the page heading code too.
Jan 16 '08 #5

Stang02GT
Expert 100+
P: 1,208
Found the solution to my problem. I placed the menu in a table and it aloud me to position it wherever i needed it to be.
Jan 18 '08 #6

acoder
Expert Mod 15k+
P: 16,027
Found the solution to my problem. I placed the menu in a table and it aloud me to position it wherever i needed it to be.
I don't think using tables for positioning is a good idea. If you use divs, or just set the left/top properties of the containing div, it'd be better. See this link for more information.
Jan 18 '08 #7

Stang02GT
Expert 100+
P: 1,208
lol unfortunately i couldn't get any suggestions or pointers form anyone and thats what i came up with doing. I mean it works fine i don't really see whats wrong with it?
Jan 18 '08 #8

acoder
Expert Mod 15k+
P: 16,027
This link might help explain.
Jan 18 '08 #9

Post your reply

Sign in to post your reply or Sign up for a free account.