|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Question about css navigation
Hello,
I have a question about how to build a navigation is css. The navigation i have so far does a swap class on a mouseover and on the mouseouts the class swaps back to the class he began with. Code:
<tr> <td width=173 height=21 class="naviglinksBT" style="cursor: hand;" onclick="parent.frames.contentHR.document.location.href='content_main.htm';" onmouseover="this.className='naviglinksBTOver';window.status='Home';return true" onmouseout="this.className='naviglinksBT';window.status='';return true">Home</td> <td rowspan=4><img src="images/cirkelsnaastKnoppen.gif" width=17 height=85></td> </tr> <tr> <td height=21 class="naviglinksBT" style="cursor: hand;" onclick="parent.frames.contentHR.document.location.href='content_nieuws.asp';" onmouseover="this.className='naviglinksBTOver';window.status='Nieuws';return true" onmouseout="this.className='naviglinksBT';window.status='';return true">Nieuws</td> </tr> <tr> <td height=21 class="naviglinksBT" style="cursor: hand;" onclick="parent.frames.contentHR.document.location.href='content_vacatures.asp';" onmouseover="this.className='naviglinksBTOver';window.status='Vacatures';return true" onmouseout="this.className='naviglinksBT';window.status='';return true">Vacatures</td> </tr> <tr> <td height=22 class="naviglinksBT2" style="cursor: hand;" onclick="parent.frames.contentHR.document.location.href='content_contactform.htm';" onmouseover="this.className='naviglinksBTOver';window.status='Contactformulier';return true" onmouseout="this.className='naviglinksBT2';window.status='';return true">Contactformulier</td> </tr> This works all fine, but now i comes the difficult part (for me that is). Now i want the navigation to be 'on' after a onClick, but it must be set to true when i click a other link (in that navigation). So when you go over the <td> it swaps a class, when you click it it takes that class and when you click on another link it must be set to the default again. Hope somebody can help me ![]() Thanks in advance. Tim |
|
#2
|
|||
|
|||
|
i had that problem too, i solved it like this
onmouseover color: #0000ff onclick color: #0000fe onmouseout color: #000000 if you want a working example of it go to http://www.primusnet.nl/top.asp and don't look at the crappy coding, i only wrote the script ![]() |
|
#3
|
|||
|
|||
|
Thanks for the reply, i will get into right away.
I really need a solution for this problem, i've played today abit and i now got that the it goes good when you only apply a onClick. But i want it to change class on a mouseover, return to true on mouseout and stays on with the onClick. I will take a look @ primus Thanks in advance.Tim Edit: The primus site didn't gave me the answer i needed .I want the whole cell to do his thing. The problem is my onMouseOut. Help meeeeeeeee! ![]() Last edited by TimvanSas : November 2nd, 2003 at 02:28 PM. |
|
#4
|
|||
|
|||
|
ok here goes
Code:
<script type="text/javascript">
MouseOverOff = '#cc0000'
MouseOverOn = '#cc0001'
Off = '#06478e'
var clicked
function clicked(button){
Parent = button.parentElement;
for (
the_buttons = 0;
the_buttons < Parent.children.length;
the_buttons ++
)
Parent.children[the_buttons].style.color=Off,
button.style.color=MouseOverOff;
}
function out(button){
if (button.style.color == MouseOverOff) button.style.color=MouseOverOff; else button.style.color=Off;
}
function over(button){
if (button.style.color == MouseOverOff) button.style.color=MouseOverOff; else button.style.color=MouseOverOn;
}
</script>
<table>
<tr>
<td onClick="clicked(this)" onMouseOver="over(this)" onMouseOut="out(this)">Button</td>
<td onClick="clicked(this)" onMouseOver="over(this)" onMouseOut="out(this)">Button</td>
<td onClick="clicked(this)" onMouseOver="over(this)" onMouseOut="out(this)">Button</td>
<td onClick="clicked(this)" onMouseOver="over(this)" onMouseOut="out(this)">Button</td>
<td onClick="clicked(this)" onMouseOver="over(this)" onMouseOut="out(this)">Button</td>
<td onClick="clicked(this)" onMouseOver="over(this)" onMouseOut="out(this)">Button</td>
</tr>
</table>
That should work, but this one only works like this, you will have to change the code a bit to get it working with anything else (like images or divs) ofcourse you can change the stylesheet too i think that should with button.class but i'm not sure Last edited by rvh : November 2nd, 2003 at 07:02 PM. |
|
#5
|
|||
|
|||
|
Thanks again rvh.
But this i have tried/done allready, it's easy and works nice. But this only change the link and i want the whole cell to change. Maybe it's very simple and am i seeing something over the head but i can't figure it out. Tim |
|
#6
|
|||
|
|||
|
just replace "button.style.color" with "button.className" and the settings (MouseOverOff = '#cc0000') with MouseOverOff = 'classname' ok?
i believe that should work |
|
#7
|
|||
|
|||
|
I've got it working.
Me and my co-worker wrote something wich is working nice. For those who are interested, here is the code we wrote: Code:
<script language="JavaScript">
var menunr = -1
function wisseluit(n) {
var strEval;
if (menunr != n) {
strEval = "document.pijl" + n + ".src = 'images/bullet-off.gif';"
eval(strEval);
strEval = "knop" + n + ".className='navknoppen';"
eval(strEval);
}
window.status='';
return true;
}
function wisselaan(s, n) {
var strEval = "document.pijl" + n + ".src = 'images/bullet-on.gif';"
eval(strEval);
var strEval = "knop" + n + ".className='navknoppenover';"
eval(strEval);
window.status= s;
return true;
}
function zetaan(n) {
if (menunr > -1) {
var strEval = "document.pijl" + menunr + ".src = 'images/bullet-off.gif';"
eval(strEval);
strEval = "knop" + menunr + ".className='navknoppen';"
eval(strEval);
}
menunr = n;
}
</script>
<br> Code:
<tr>
<td id='knop1' colspan=3 class="navknoppen" onclick="zetaan(1);" onmouseover="wisselaan('Contact', 1);" onmouseout="wisseluit(1)"><img src="images/bullet-off.gif" name="pijl1" width="4" height="7"> Contactformulier</td>
</tr>
<tr>
<td id='knop2' colspan=3 class="navknoppen" onclick="zetaan(2);" onmouseover="wisselaan('Downloads', 2);" onmouseout="wisseluit(2)"><img src="images/bullet-off.gif" name="pijl2" width="4" height="7"> Downloads</td>
</tr>
<tr>
<td id='knop3' colspan=3 class="navknoppen" onclick="zetaan(3);" onmouseover="wisselaan('Links', 3);" onmouseout="wisseluit(3)"><img src="images/bullet-off.gif" name="pijl3" width="4" height="7"> Links</td>
</tr>
<tr>
<td id='knop4' colspan=3 class="navknoppen" onclick="zetaan(4);" onmouseover="wisselaan('Bedrijfsinformatie', 4);" onmouseout="wisseluit(4)"><img src="images/bullet-off.gif" name="pijl4" width="4" height="7"> Bedrijfsinformatie</td>
</tr>
<tr>
<td id='knop5' colspan=3 class="navknoppen" onclick="zetaan(5);" onmouseover="wisselaan('test', 5);" onmouseout="wisseluit(5)"><img src="images/bullet-off.gif" name="pijl5" width="4" height="7"> test</td>
</tr>
Thanks for your time and advice rvh! Tim Last edited by TimvanSas : November 3rd, 2003 at 06:25 AM. |
|
#8
|
|||
|
|||
|
I would replace onclick="zetaan(1);" with onclick="zetaan(this);"
then you will not have to put the numbers in it anymore, just a bit easyer ![]() nice script though ![]() |
![]() |
| Viewing: Dev Shed Forums > Web Design > CSS Help > Question about css navigation |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|