View Full Version : Javascript Menu


nathansgurl
12-19-2004, 06:20 PM
Hey, want to use the code below to make a menu with submenus. Its working put the thing is after I hover over the thing, the sub menu comes up but once I move away, the sub menu continues to be visible. How can I make the submenus disappear once I move a way from the button? Thanks in Advance :) !

Poulami

<!-- Begin Script by Blogring.net -->
<CENTER><FONT size:10pt font ms trebuchet family:>

<A onmouseover=showit(0)
href="http://www.xanga.com/">XANGA</A> <A onmouseover=showit(1)
href="http://www.xanga.com/private/home.aspx">controls</A>
<A
onmouseover=showit(2) href="http://www.xanga.com/YOURNAME">YOURNAME</B></A>
* <A onmouseover=showit(3) href="http://www.xanga.com/blogrings">BLOGRINGS</A> *
<BR><ILAYER bgColor="#" name="dep1" height="32" width="400"><LAYER name="dep2"
height="30" width="400"></LAYER></ILAYER>
<DIV id=describe onmouseover=clear_delayhide()
style="WIDTH: 500px; HEIGHT: 10px" onmouseout=resetit(event)></DIV>
<script language=JavaScript1.2>

/*
Tabs Menu (mouseover)- By Dynamic Drive
For full source code and more DHTML scripts, visit http://www.dynamicdrive.com
This credit MUST stay intact for use
*/

http://premium.xanga.com/Private/Premium/xtools.asp?reload=/private/home.aspx

var submenu=new Array()

//Set submenu contents. Expand as needed. For each content, make sure everything exists on ONE LINE. Otherwise, there will be JS errors.

submenu[0]='<font size="1" face="trebuchet ms">- <a href="http://www.xanga.com/signin.asp">sign in</a> - <a href="http://www.xanga.com/logout.asp">log out</a> - <a href="http://www.xanga.com/register.asp">membership</a> -</font>'

submenu[1]='<font size="1" face="trebuchet ms">- <a href="http://www.xanga.com/CLAF/default.asp">look&feel</a> - <a href="http://xanga.com/private/subscriptions.aspx">subscriptionz</a> - <a href="http://xanga.com/private/feedback.aspx">feedback logz</a> - </font>'

submenu[2]='<font size="1" face="trebuchet ms">- <a href="http://www.xanga.com/Private/SubscribeTo.aspx?user=Oomi12acleoO">subscribe now</a> - <a href="http://www.xanga.com/guestbook.asp?user=YOURNAME">sign g-book</a> -</font>'

submenu[3]='<font size="1" face="trebuchet ms">- <a href="http://www.xanga.com/blogrings/blogring.asp?id=#####">BLOGRING1</a> - <a href="http://www.xanga.com/blogrings/blogring.asp?id=#####">BLOGRING2</a> - <a href="http://www.xanga.com/blogrings/blogring.asp?id=14975">BLOGRING3</a> - <a href="http://www.xanga.com/blogrings/blogring.asp?id=#####">BLOGRING4</a> -</font>'

//Set delay before submenu disappears after mouse moves out of it (in milliseconds)
var delay_hide=500

/////No need to edit beyond here

var menuobj=document.getElementById? document.getElementById("describe") : document.all? document.all.describe : document.layers? document.dep1.document.dep2 : ""

function showit(which){
clear_delayhide()
thecontent=(which==-1)? "" : submenu[which]
if (document.getElementById||document.all)
menuobj.innerHTML=thecontent
else if (document.layers){
menuobj.document.write(thecontent)
menuobj.document.close()
}
}

function resetit(e){
if (document.all&&!menuobj.contains(e.toElement))
delayhide=setTimeout("showit(-1)",delay_hide)
else if (document.getElementById&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget))
delayhide=setTimeout("showit(-1)",delay_hide)
}

function clear_delayhide(){
if (window.delayhide)
clearTimeout(delayhide)
}

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

</SCRIPT>

Aisha_girl
12-19-2004, 09:44 PM
well im not sure about that code or anything.. maybe u can use this code and put the hover code in it also.. but for the submenu code (only appears when your mouse goes over it)::

Submenu on top
<CENTER><FONT size:10pt font ms trebuchet family:><A onmouseover=showit(0) href="http://www.xanga.com/">XANGA</A> <A onmouseover=showit(1) href="http://www.xanga.com/private/home.aspx">controls</A> <A onmouseover=showit(2) href="http://www.xanga.com/YOURNAME">YOURNAME</B></A> * <A onmouseover=showit(3) href="http://www.xanga.com/blogrings">BLOGRINGS</A> * <BR><ILAYER bgColor="#" name="dep1" height="32" width="400"><LAYER name="dep2" height="30" width="400"></LAYER></ILAYER><DIV id=describe onmouseover=clear_delayhide() style="WIDTH: 500px; HEIGHT: 10px" onmouseout=resetit(event)></DIV><script language=JavaScript1.2>/*Tabs Menu (mouseover)- By Dynamic DriveFor full source code and more DHTML scripts, visit http://www.dynamicdrive.comThis credit MUST stay intact for use*/http://premium.xanga.com/Private/Premium/xtools.asp?reload=/private/home.aspxvar submenu=new Array()//Set submenu contents. Expand as needed. For each content, make sure everything exists on ONE LINE. Otherwise, there will be JS errors.submenu[0]='<font size="1" face="trebuchet ms">- <a href="http://www.xanga.com/signin.asp">sign in</a> - <a href="http://www.xanga.com/logout.asp">log out</a> - <a href="http://www.xanga.com/register.asp">membership</a> -</font>'submenu[1]='<font size="1" face="trebuchet ms">- <a href="http://www.xanga.com/CLAF/default.asp">look&feel</a> - <a href="http://xanga.com/private/subscriptions.aspx">subscriptionz</a> - <a href="http://xanga.com/private/feedback.aspx">feedback logz</a> - </font>'submenu[2]='<font size="1" face="trebuchet ms">- <a href="http://www.xanga.com/Private/SubscribeTo.aspx?user=Oomi12acleoO">subscribe now</a> - <a href="http://www.xanga.com/guestbook.asp?user=YOURNAME">sign g-book</a> -</font>'submenu[3]='<font size="1" face="trebuchet ms">- <a href="http://www.xanga.com/blogrings/blogring.asp?id=#####">BLOGRING1</a> - <a href="http://www.xanga.com/blogrings/blogring.asp?id=#####">BLOGRING2</a> - <a href="http://www.xanga.com/blogrings/blogring.asp?id=14975">BLOGRING3</a> - <a href="http://www.xanga.com/blogrings/blogring.asp?id=#####">BLOGRING4</a> -</font>'//Set delay before submenu disappears after mouse moves out of it (in milliseconds)var delay_hide=500/////No need to edit beyond herevar menuobj=document.getElementById? document.getElementById("describe") : document.all? document.all.describe : document.layers? document.dep1.document.dep2 : ""function showit(which){clear_delayhide()thecontent=(which==-1)? "" : submenu[which]if (document.getElementById||document.all)menuobj.inn erHTML=thecontentelse if (document.layers){menuobj.document.write(theconten t)menuobj.document.close()}}function resetit(e){if (document.all&&!menuobj.contains(e.toElement))delayhide=("showit(-1)",delay_hide)else if (document.getElementById&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget))delayhide=("showit(-1)",delay_hide)}function clear_delayhide(){if (window.delayhide)clearTimeout(delayhide)}function contains_ns6(a, b) {while (b.parentNode)if ((b = b.parentNode) == a)return true;return false;}</SCRIPT>

im not sure if that was what you were looking for but i hope i helped
:lolol: =]