PDA

View Full Version : onclick help



Divvy
Aug 25th, 2005, 09:23 PM
Hi guys!
I am using this code in my phpBB menu.
But I need help...
The menu opens with mouse over and I need to open with onclick

Can someone help me please? :)



function init() {
if (document.all&&document.getElementById) {
navRoot = document.getElementById("dmenu");
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", "");
}
}
}
}

}


Thanks and sorry for my bad english hehe

Brandoe85
Aug 25th, 2005, 09:46 PM
Try:


function init() {
if (document.all&&document.getElementById) {
navRoot = document.getElementById("dmenu");
for (i=0; i<navRoot.childNodes.length; i++) {
node = navRoot.childNodes[i];
if (node.nodeName=="LI") {
node.onmouseover=function() {
this.className+=" over";
}
node.onclick=function() {
this.className=this.className.replace(" over", "");
}
}
}
}

}

Divvy
Aug 25th, 2005, 10:08 PM
Thanks Brandoe85 :)
But donīt work...
Menu opens on mouse over and donīt close... stay open...

anymore suggestion? ;)

Brandoe85
Aug 25th, 2005, 11:08 PM
Bah!


function init() {
if (document.all&&document.getElementById) {
navRoot = document.getElementById("dmenu");
for (i=0; i<navRoot.childNodes.length; i++) {
node = navRoot.childNodes[i];
if (node.nodeName=="LI") {
node.onclick=function() {
this.className+=" over";
}
node.onclick=function() {
this.className=this.className.replace(" over", "");
}
}
}
}

}

Divvy
Aug 25th, 2005, 11:14 PM
I already tryed this but menu donīt open :(

Maybe this helps... is the entire mod:


#-----[ COPY ]------------------------------------------
#
menu.js > menu.js

#
#-----[ OPEN ]------------------------------------------
#
templates/subSilver/overall_header.tpl

#
#-----[ FIND ]------------------------------------------
#
/* Import the fancy styles for IE only (NS4.x doesn't use the @import function) */
@import url("templates/subSilver/formIE.css");

#
#-----[ AFTER, ADD ]------------------------------------------
#
/* Top-Nav */
.topmenuul {
PADDING-RIGHT: 0px; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-TOP: 0px; LIST-STYLE-TYPE: none
}
.topmenuli {
FLOAT: left; LIST-STYLE-TYPE: none
}
.topmenutitle {
DISPLAY: block; WIDTH: 100px
}
.submenuul {
PADDING-RIGHT: 0px; DISPLAY: none; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-TOP: 0px; LIST-STYLE-TYPE: none; POSITION: absolute
}
.submenuli A {
DISPLAY: block; WIDTH: 100px
}
LI:hover UL {DISPLAY: block}
LI.over UL {DISPLAY: block}
UNKNOWN {LEFT: auto; TOP: auto}
.content {CLEAR: left}

#dmenu {
FONT-SIZE: 11px; FONT-FAMILY: Arial, Helvetica, Sans-Serif
}
.topmenuul {}
.topmenutitle {
BORDER-RIGHT: #cedcec 1px solid; PADDING-RIGHT: 3px; BORDER-TOP: #cedcec 1px solid; PADDING-LEFT: 3px; PADDING-BOTTOM: 3px; BORDER-LEFT: #cedcec 1px solid; COLOR: #000000; TEXT-INDENT: 3px; LINE-HEIGHT: 14px; PADDING-TOP: 3px; BORDER-BOTTOM: #cedcec 1px solid; BACKGROUND-COLOR: #eaedf4; TEXT-DECORATION: none
}
.submenuul {
BORDER-RIGHT: #000000 2px solid; BACKGROUND-POSITION: left top; BORDER-TOP: #000000 1px solid; MARGIN-TOP: -1px; BORDER-LEFT: #cedcec 7px solid; BORDER-BOTTOM: #000000 2px solid; BACKGROUND-REPEAT: repeat-x; BACKGROUND-COLOR: #cedcec
}
.submenuli A {
PADDING-RIGHT: 3px; PADDING-LEFT: 3px; PADDING-BOTTOM: 3px; COLOR: #000000; PADDING-TOP: 3px; BACKGROUND-COLOR: #EFEFEF; TEXT-DECORATION: none
}


.submenuli A:hover {
COLOR: #000000; BACKGROUND-COLOR: #cedcec; TEXT-DECORATION: none
}
#
#-----[ FIND ]------------------------------------------
#
</head>

#
#-----[ BEFORE, ADD ]------------------------------------------
#
<script language="JavaScript" src="menu.js"></SCRIPT>

#
#-----[ FIND ]------------------------------------------
#
<body onload="init();" bgcolor="{T_BODY_BGCOLOR}" text="{T_BODY_TEXT}" link="{T_BODY_LINK}" vlink="{T_BODY_VLINK}">


#
#-----[ IN-LINE FIND ]------------------------------------------
#
<body

#
#-----[ IN-LINE AFTER, ADD ]------------------------------------------
#
onload="init();"

#
#-----[ FIND ]------------------------------------------
#
<table cellspacing="0" cellpadding="2" border="0">
<tr>
<td align="center" valign="top" nowrap="nowrap"><span class="mainmenu">&nbsp;<a href="{U_FAQ}" class="mainmenu"><img src="templates/subSilver/images/icon_mini_faq.gif" width="12" height="13" border="0" alt="{L_FAQ}" hspace="3" />{L_FAQ}</a></span><span class="mainmenu">&nbsp; &nbsp;<a href="{U_SEARCH}" class="mainmenu"><img src="templates/subSilver/images/icon_mini_search.gif" width="12" height="13" border="0" alt="{L_SEARCH}" hspace="3" />{L_SEARCH}</a>&nbsp; &nbsp;<a href="{U_MEMBERLIST}" class="mainmenu"><img src="templates/subSilver/images/icon_mini_members.gif" width="12" height="13" border="0" alt="{L_MEMBERLIST}" hspace="3" />{L_MEMBERLIST}</a>&nbsp; &nbsp;<a href="{U_GROUP_CP}" class="mainmenu"><img src="templates/subSilver/images/icon_mini_groups.gif" width="12" height="13" border="0" alt="{L_USERGROUPS}" hspace="3" />{L_USERGROUPS}</a>&nbsp;
<!-- BEGIN switch_user_logged_out -->
&nbsp;<a href="{U_REGISTER}" class="mainmenu"><img src="templates/subSilver/images/icon_mini_register.gif" width="12" height="13" border="0" alt="{L_REGISTER}" hspace="3" />{L_REGISTER}</a></span>&nbsp;
<!-- END switch_user_logged_out -->

</td>
</tr>
<tr>
<td height="25" align="center" valign="top" nowrap="nowrap"><span class="mainmenu">&nbsp;<a href="{U_PROFILE}" class="mainmenu"><img src="templates/subSilver/images/icon_mini_profile.gif" width="12" height="13" border="0" alt="{L_PROFILE}" hspace="3" />{L_PROFILE}</a>&nbsp; &nbsp;<a href="{U_PRIVATEMSGS}" class="mainmenu"><img src="templates/subSilver/images/icon_mini_message.gif" width="12" height="13" border="0" alt="{PRIVATE_MESSAGE_INFO}" hspace="3" />{PRIVATE_MESSAGE_INFO}</a>&nbsp; &nbsp;<a href="{U_LOGIN_LOGOUT}" class="mainmenu"><img src="templates/subSilver/images/icon_mini_login.gif" width="12" height="13" border="0" alt="{L_LOGIN_LOGOUT}" hspace="3" />{L_LOGIN_LOGOUT}</a>&nbsp;</span>
</td>
</tr>
</table>


#
#-----[ REPLACE WITH ]------------------------------------------
#
<table cellspacing="0" cellpadding="2" border="0">
<tr>
<td align="center" valign="top" nowrap="nowrap"><span class="mainmenu">
<!-- BEGIN switch_user_logged_out -->
<a href="{U_REGISTER}" class="mainmenu"><img src="templates/subSilver/images/icon_mini_register.gif" width="12" height="13" border="0" alt="{L_REGISTER}" hspace="3" />{L_REGISTER}</a></span>
<!-- END switch_user_logged_out -->
<a href="{U_LOGIN_LOGOUT}" class="mainmenu"><img src="templates/subSilver/images/icon_mini_login.gif" width="12" height="13" border="0" alt="{L_LOGIN_LOGOUT}" hspace="3" />{L_LOGIN_LOGOUT}</a>&nbsp;
<a href="{U_PRIVATEMSGS}" class="mainmenu"><img src="templates/subSilver/images/icon_mini_message.gif" width="12" height="13" border="0" alt="{PRIVATE_MESSAGE_INFO}" hspace="3" />{PRIVATE_MESSAGE_INFO}</a>
</td>
</tr>
</table>
<table width="100%" align="center">
<tr>
<td width="20%"></td>
<td>
<ul class="topmenu" id="dmenu">
<li class="topmenuli"><a class="topmenutitle">Board</a>
<ul class="submenuul">
<li class="submenuli"><a href="index.php"><img src="templates/subSilver/images/icon_mini_members.gif" width="12" height="13" border="0" alt="{L_MEMBERLIST}" hspace="3" />Forum</a>
<li class="submenuli"><a href="faq.php"><img src="templates/subSilver/images/icon_mini_faq.gif" width="12" height="13" border="0" alt="{L_FAQ}" hspace="3" />FAQ</a>
</LI>
</UL>
</LI>
<LI class="topmenuli"><a class="topmenutitle">User</A>
<UL class="submenuul">
<LI class="submenuli"><a href="{U_PROFILE}"><img src="templates/subSilver/images/icon_mini_profile.gif" width="12" height="13" border="0" alt="{L_PROFILE}" hspace="3" />Profil</a>
<LI class="submenuli"><a href="{U_MEMBERLIST}"><img src="templates/subSilver/images/icon_mini_members.gif" width="12" height="13" border="0" alt="{L_MEMBERLIST}" hspace="3" />Mitgliederliste</a>
</LI>
</UL>
</LI>
<li class="topmenuli"><a class="topmenutitle">Interaktiv</a>
<ul class="submenuul">
<li class="submenuli"><a href="{U_SEARCH}"><img src="templates/subSilver/images/icon_mini_search.gif" width="12" height="13" border="0" alt="{L_SEARCH}" hspace="3" />{L_SEARCH}</a>
</LI>
</UL>
</LI>
<li class="topmenuli"><a class="topmenutitle">Your Text</a>
<ul class="submenuul">
<li class="submenuli"><a href="#">...</a>
<li class="submenuli"><a href="#">...</a>
<li class="submenuli"><a href="#">...</a>
<li class="submenuli"><a href="#">...</a>
</LI>
</UL>
</LI>
<li class="topmenuli"><a class="topmenutitle">Your Text</a>
<ul class="submenuul">
<li class="submenuli"><a href="#">...</a>
<li class="submenuli"><a href="#">...</a>
<li class="submenuli"><a href="#">...</a>
</LI>
</UL>
</LI>
</UL>
</td></tr>
</table>
<div class="content">



#
#-----[ SAVE/CLOSE ALL FILES ]------------------------------------------

My forum url: http://www.divertidos.net/viciadosnosexo/index.php

Thanks :)

Divvy
Aug 26th, 2005, 02:05 AM
anyone? :(