home hardware prices news articles forums photos user reviews
Go Back   Tech Support Forums - TechIMO.com > PC Hardware and Tech > Webmastering and Programming
Ask a Tech Support Question (free)!

Javascript Menu

Reply
Get bargains at  »  Dealighted.com
 
Thread Tools Search this Thread
Currently Active Users: 1637
Discussions: 200,988, Posts: 2,379,865, Members: 246,356
Old June 20th, 2006, 11:28 PM   Digg it!   #1 (permalink)
SoMuchAnime-SoLittleTime
 
EXreaction's Avatar
 
Join Date: Aug 2003
Location: Plymouth, WI
Posts: 14,984
Blog Entries: 1
Send a message via MSN to EXreaction
Javascript Menu

Hey guys, I am working on the templates for my new(once I get my credit card so I can order hosting) site.

The menu I would like to setup is something like the menu at newegg.com where you slide over an option and some more options come up(I dont know the exact name of it, which is why I am having trouble figuring it out(google can't search without a name )

Any links or examples of it?
__________________
My photography: Flickr

Lithium Studios - phpBB3, PHP, and Web Development
EXreaction is offline   Reply With Quote
Old June 20th, 2006, 11:32 PM     #2 (permalink)
Super Stealthy Moderator
 
RicheemxX's Avatar
 
Join Date: Jan 2003
Location: Outside the box
Posts: 5,560
Blog Entries: 4
Send a message via Yahoo to RicheemxX
here's what i use sorry its kind of long
<script type="text/javascript">



//Contents for menu 1
var menu1=new Array()
menu1[0]='<a href="http://www.spoofee.com/">Spoofee Deals</a>'
menu1[1]='<A HREF="http://www.fatwallet.com/">FatWallet.Com </A>'
menu1[2]='<A HREF="http://www.slickdeals.net/">SlickDeals.net</A>'
menu1[3]='<A HREF="http://www.techbargains.com/index.cfm">Techbargains.com</A>'
menu1[4]='<A HREF="http://resellerratings.com/">ResellerRatings</A>'



//Contents for menu 2
var menu2=new Array()
menu2[0]='<A HREF="http://www.techimo.com/forum/index.html">TechImo</a>'
menu2[1]='<A HREF="http://hardforum.com/index.php?">[H]ardForums</a>'
menu2[2]='<A HREF="http://www.amdzone.com/">AmdZone</a>'
menu2[3]='<A HREF="http://forums.anandtech.com/login.cfm">AnandTech</a>'
menu2[4]='<A HREF="http://www.aoaforums.com/forum/">AoAforums</a>'
menu2[5]='<A HREF="http://www.ocworkbench.com/index.stm">OcWorkbench</a>'




var menuwidth='165px'
var menubgcolor='black'
var disappeardelay=250
var hidemenu_onclick="yes"



var ie4=document.all
var ns6=document.getElementById&&!document.all

if (ie4||ns6)
document.write('<div id="dropmenudiv" style="visibility:hidden;width:'+menuwidth+';backg round-color:'+menubgcolor+'" onMouseover="clearhidemenu()" onMouseout="dynamichide(event)"></div>')

function getposOffset(what, offsettype){
var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
var parentEl=what.offsetParent;
while (parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
}


function showhide(obj, e, visible, hidden, menuwidth){
if (ie4||ns6)
dropmenuobj.style.left=dropmenuobj.style.top=-500
if (menuwidth!=""){
dropmenuobj.widthobj=dropmenuobj.style
dropmenuobj.widthobj.width=menuwidth
}
if (e.type=="click" && obj.visibility==hidden || e.type=="mouseover")
obj.visibility=visible
else if (e.type=="click")
obj.visibility=hidden
}

function iecompattest(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function clearbrowseredge(obj, whichedge){
var edgeoffset=0
if (whichedge=="rightedge"){
var windowedge=ie4 && !window.opera? iecompattest().scrollLeft+iecompattest().clientWid th-15 : window.pageXOffset+window.innerWidth-15
dropmenuobj.contentmeasure=dropmenuobj.offsetWidth
if (windowedge-dropmenuobj.x < dropmenuobj.contentmeasure)
edgeoffset=dropmenuobj.contentmeasure-obj.offsetWidth
}
else{
var topedge=ie4 && !window.opera? iecompattest().scrollTop : window.pageYOffset
var windowedge=ie4 && !window.opera? iecompattest().scrollTop+iecompattest().clientHeig ht-15 : window.pageYOffset+window.innerHeight-18
dropmenuobj.contentmeasure=dropmenuobj.offsetHeigh t
if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure){ //move up?
edgeoffset=dropmenuobj.contentmeasure+obj.offsetHe ight
if ((dropmenuobj.y-topedge)<dropmenuobj.contentmeasure) //up no good either?
edgeoffset=dropmenuobj.y+obj.offsetHeight-topedge
}
}
return edgeoffset
}

function populatemenu(what){
if (ie4||ns6)
dropmenuobj.innerHTML=what.join("")
}


function dropdownmenu(obj, e, menucontents, menuwidth){
if (window.event) event.cancelBubble=true
else if (e.stopPropagation) e.stopPropagation()
clearhidemenu()
dropmenuobj=document.getElementById? document.getElementById("dropmenudiv") : dropmenudiv
populatemenu(menucontents)

if (ie4||ns6){
showhide(dropmenuobj.style, e, "visible", "hidden", menuwidth)
dropmenuobj.x=getposOffset(obj, "left")
dropmenuobj.y=getposOffset(obj, "top")
dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+"px"
dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+obj.offsetHeight+"px"
}

return clickreturnvalue()
}

function clickreturnvalue(){
if (ie4||ns6) return false
else return true
}

function contains_ns6(a, b) {
while (b.parentNode)
if ((b = b.parentNode) == a)
return true;
return false;
}

function dynamichide(e){
if (ie4&&!dropmenuobj.contains(e.toElement))
delayhidemenu()
else if (ns6&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget))
delayhidemenu()
}

function hidemenu(e){
if (typeof dropmenuobj!="undefined"){
if (ie4||ns6)
dropmenuobj.style.visibility="hidden"
}
}

function delayhidemenu(){
if (ie4||ns6)
delayhide=setTimeout("hidemenu()",disappeardelay)
}

function clearhidemenu(){
if (typeof delayhide!="undefined")
clearTimeout(delayhide)
}

if (hidemenu_onclick=="yes")
document.onclick=hidemenu

</script>
__________________
“Every question involves someone having to work for an answer, isn't it about time you did your share”
"Non-technical questions sometimes don't have an answer at all."
Linus Torvalds
RicheemxX is offline   Reply With Quote
Old June 20th, 2006, 11:34 PM     #3 (permalink)
Super Stealthy Moderator
 
RicheemxX's Avatar
 
Join Date: Jan 2003
Location: Outside the box
Posts: 5,560
Blog Entries: 4
Send a message via Yahoo to RicheemxX
here's a decent site with info http://www.alistapart.com/articles/horizdropdowns
RicheemxX is offline   Reply With Quote
Old June 20th, 2006, 11:39 PM     #4 (permalink)
SoMuchAnime-SoLittleTime
 
EXreaction's Avatar
 
Join Date: Aug 2003
Location: Plymouth, WI
Posts: 14,984
Blog Entries: 1
Send a message via MSN to EXreaction
Hmm, that link looks like it has just the stuff I need.
EXreaction is offline   Reply With Quote
Old June 20th, 2006, 11:43 PM     #5 (permalink)
Super Stealthy Moderator
 
RicheemxX's Avatar
 
Join Date: Jan 2003
Location: Outside the box
Posts: 5,560
Blog Entries: 4
Send a message via Yahoo to RicheemxX
yeah the one i use is pretty basic drop down menu however you can get more complex horizontal<i think thats what they are called> menus like what newegg has
RicheemxX is offline   Reply With Quote
Old June 21st, 2006, 12:19 PM     #6 (permalink)
SoMuchAnime-SoLittleTime
 
EXreaction's Avatar
 
Join Date: Aug 2003
Location: Plymouth, WI
Posts: 14,984
Blog Entries: 1
Send a message via MSN to EXreaction
Quote:
Originally Posted by RicheemxX
yeah the one i use is pretty basic drop down menu however you can get more complex horizontal<i think thats what they are called> menus like what newegg has

Ya, I am going to make images for it instead of words and have buttons slide down.
EXreaction is offline   Reply With Quote
Old June 21st, 2006, 08:28 PM     #7 (permalink)
SoMuchAnime-SoLittleTime
 
EXreaction's Avatar
 
Join Date: Aug 2003
Location: Plymouth, WI
Posts: 14,984
Blog Entries: 1
Send a message via MSN to EXreaction
Hmm, I seem to have a problem with IE 6...IE doesn't have the drop downs when you hover over it.

I am using:
Code:
<ul> 
	<li><a><b>Other stuff</b></a> 
		<ul> 
			<li class="css_menu"><a href="viewtopic.php?f=4&t=12">Web Services</a></li> 
			<li class="css_menu"><a href="../phpbb2/index.php">phpBB2 Demo Forum</a></li> 
		</ul> 
	</li> 
</ul>
(I cut out a bunch that is the same thing except with different links)

And the CSS style:
Code:
/* CSS Menu
 ------------ */

.css_menu {
	background: #fff;
	border: 1px solid #ccc; /* IE6 Bug */
	}

.css_menu:hover {
	background: #ececec;
	}

ul {
	margin: 0;
	padding: 0;
	list-style: none;
	border-bottom: 0px solid #ccc;
	}

ul li {
	position: relative;
	}
	
li ul {
	position: absolute;
	top: 20px;
	display: none;
	}

ul li a {
	display: block;
	text-decoration: none;
	color: #777;
	padding: 5px;
	border: 0px solid #ccc; /* IE6 Bug */
	border-bottom: 0;
	}

* html ul li { float: left; height: 1%; }
* html ul li a { height: 1%; }
		
li:hover ul { display: block; }
EXreaction is offline   Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Similar Threads
Thread Thread Starter Forum Replies Last Post
trouble with javascript menu reference. daedreem Webmastering and Programming 3 January 24th, 2006 09:41 PM
javascript help - customizing drop select menu border color Namie Graphic Design and Digital Photography 0 September 28th, 2005 04:45 AM
Help with JavaScript menu problem (positioning) Francesca Webmastering and Programming 7 October 7th, 2003 07:57 PM
Added JavaScript and it totally cocked up my menu bar :( Fade2Grey Webmastering and Programming 4 March 18th, 2003 11:36 PM


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Most Active Discussions
Is It Just Me? (3066)
Charges against non-tippers dropped.. (20)
Health Care Rationing (11)
Delete an OS (17)
Nvidia GTX 260 problem (10)
Laptop with wireless problem. (12)
windows vista security holes (19)
Wireless Televisions. (12)
CPU fan stops spinning randomly (11)
Regular Build (11)
Point and Shoot Camera Suggestions. (8)
windows 7 problem (7)
[F@H SPAM 11/16/09] ! 1/2 months to.. (39)
Internet Lost (5)
Recent Discussions
Can a page file be "too big".. (1)
Nvidia GTX 260 problem (10)
Point and Shoot Camera Suggestions. (8)
Looking for new motherboard (0)
Size after cutting 700Mb file is 2.5 .. (0)
Delete an OS (17)
[F@H SPAM 11/16/09] ! 1/2 months to r.. (39)
windows vista security holes (19)
updating BIOS via winflash, claims fi.. (1)
New Server Configuration Suggestions (0)
Desktop Calendar Application (0)
cheap gaming laptop? (12)
Unallocated Space (2)
help me pls laptop just stopped worki.. (1)
C# + LINQ Help (7)
Dynex DX E-402 (3)
EVGA 9800 gtx help with finding a goo.. (12)
Multiple Restarts Required at Boot (5)
cell phone won't work (0)
Is the PSU I received dead? (15)
Can't open Word (12)
Steam ID's, Gamertags etc... (4)
Games, Cables, PCI cards, and more fo.. (6)
Dept. of HS: NSA 'Helped' Develop Vis.. (17)
Linksys WMP54GS wireless card problem.. (5)


All times are GMT -4. The time now is 06:35 AM.
TechIMO Copyright 2009 All Enthusiast, Inc.



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28