Connecting Tech Pros Worldwide Forums | Help | Site Map

tab menu - change tabs onmouseover, onmouseout, onclick

oll3i's Avatar
Site Addict
 
Join Date: Mar 2007
Posts: 563
#1: Jul 2 '08
i wrote css class for a href but when i add this class to link it doesnt see the image but when i add the inline css it sees it
i m writing javascript tab menu and i want tabs to change on mouse over, on mouse out and on click
Expand|Select|Wrap|Line Numbers
  1. a.menu_on_mouse_over{
  2. width:80px;
  3. height:22px;
  4. float:left;
  5. text-align:center;
  6. margin-top:0;
  7. margin-right:1px;
  8. margin-bottom:0;
  9. margin-left:0;
  10. font-size:100%;
  11. text-decoration:none;
  12. color:#FFF;
  13. font-weight:bold;
  14. background:url(../images/top_menu_hover.gif) left top no-repeat;  
  15. padding:3px 0 0 0;
  16. }
  17.  

the css is in css/menu.css
and images are in folder
images/top_menu_hover.gif

oll3i's Avatar
Site Addict
 
Join Date: Mar 2007
Posts: 563
#2: Jul 2 '08

re: tab menu - change tabs onmouseover, onmouseout, onclick


in js menu i have
Expand|Select|Wrap|Line Numbers
  1. document.write('<li style="display:inline;"><a href=\'/HRDB/candidates/index.jsp?sortby=name,f=1,switch_f=1,modul=candidates\'  onclick="className=\'menu_on_mouse_over\'" onmouseover="className=\'menu_on_mouse_over\'" onmouseout="className=\'menu_on_mouse_out\'" class="menu_on_mouse_out">');
  2. document.write(this.var1);
  3. document.write('</a></li>');
  4.  
thank You
oll3i's Avatar
Site Addict
 
Join Date: Mar 2007
Posts: 563
#3: Jul 2 '08

re: tab menu - change tabs onmouseover, onmouseout, onclick


maybe i should have posted it on javascript forum?
oll3i's Avatar
Site Addict
 
Join Date: Mar 2007
Posts: 563
#4: Jul 2 '08

re: tab menu - change tabs onmouseover, onmouseout, onclick


i got back to my jsp project i don't know how to write js tab menu without document.write as You suggested before so I'm stuck

i wrote css class for a href but when i add this class to link it doesnt see the tab background image but when i add the inline css it sees it
i want tabs to change on mouse over, on mouse out and on click

Expand|Select|Wrap|Line Numbers
  1. a.menu_on_mouse_over{
  2. width:80px;
  3. height:22px;
  4. float:left;
  5. text-align:center;
  6. margin-top:0;
  7. margin-right:1px;
  8. margin-bottom:0;
  9. margin-left:0;
  10. font-size:100%;
  11. text-decoration:none;
  12. color:#FFF;
  13. font-weight:bold;
  14. background:url(../images/top_menu_hover.gif) left top no-repeat;  
  15. padding:3px 0 0 0;
  16. }
  17.  
  18.  
and then in menu.js file in display function i have
Expand|Select|Wrap|Line Numbers
  1. document.write('<li style="display:inline;"><a href=\'/HRDB/candidates/index.jsp?sortby=name,f=1,switch_f=1,modul=candidates\'  onclick="className=\'menu_on_mouse_over\'" onmouseover="className=\'menu_on_mouse_over\'" onmouseout="className=\'menu_on_mouse_out\'" class="menu_on_mouse_out">');
  2. document.write(this.var1);
  3. document.write('</a></li>');
  4.  
it doesnt throw any error now

the css is in css/menu.css
and images are in folder
images/top_menu_hover.gif

thank You
acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,581
#5: Jul 2 '08

re: tab menu - change tabs onmouseover, onmouseout, onclick


Rather than just className, you need this.className.

PS. merged threads.
oll3i's Avatar
Site Addict
 
Join Date: Mar 2007
Posts: 563
#6: Jul 2 '08

re: tab menu - change tabs onmouseover, onmouseout, onclick


thanks for merging threads
... but even with "this" still doesn't work
acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,581
#7: Jul 2 '08

re: tab menu - change tabs onmouseover, onmouseout, onclick


Where is the display function called?
oll3i's Avatar
Site Addict
 
Join Date: Mar 2007
Posts: 563
#8: Jul 3 '08

re: tab menu - change tabs onmouseover, onmouseout, onclick


the display finction is called in my jsp file
Expand|Select|Wrap|Line Numbers
  1. <script>
  2. var menu = new Menu();
  3. menu.display();
  4. </script>
  5.  
look please at the document.write in my 4th post this line is part of display function
acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,581
#9: Jul 3 '08

re: tab menu - change tabs onmouseover, onmouseout, onclick


Is it just the image that it's not finding or none of the CSS rules are being applied?
oll3i's Avatar
Site Addict
 
Join Date: Mar 2007
Posts: 563
#10: Jul 3 '08

re: tab menu - change tabs onmouseover, onmouseout, onclick


hmm i forgot to add css file to jsp file hihi it works now :) thank You next time i will know that i have to check if i included the file first before i post something but it happens sometimes
acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,581
#11: Jul 3 '08

re: tab menu - change tabs onmouseover, onmouseout, onclick


Barking up the wrong tree all along, eh? As you say, it happens. Glad you've got it sorted.
Reply


Similar JavaScript / Ajax / DHTML bytes