| | |
Look for suggestion for changed color menu
Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Oct 2008
Posts: 63
Reputation:
Solved Threads: 0
html Syntax (Toggle Plain Text)
<form name="menu"> <font face="Comic Sans MS " size="4" > <table id="menutable" name="table1" frame="void" rules="none" > <ul> <tr ><li><a href="main.html" onmouseover="ChangeCol();" id="ch1" target="main">Main Page</a><br/></tr> <tr><li><a href="photos.html" name="photos" target="main">Photos of Australia</a><br/></tr> <tr><li><a href="immigration.html" name="immigration" target="main">Immigration</a><br/></tr> <tr><li><a href="question.html" name="q" target="main">Questions</a><br/></tr> <tr><li><a href="job.html" name="job" target="main">All about Job</a><br/></tr> <tr><li><a href="studies.html" name="study" target="main">All about Studies</a><br/></tr> <tr><li><a href="chat.html" name="chat" target="main">Chat</a><br/></tr> <tr><li><a href="forum.html" name="forum" target="main">Forum about Anything</a><br/><tr> <tr><li><a href="links.html" name="link" target="main">Intresting Links</a><br/></tr> <tr><li><a href="price.html" name="price" target="main">Prices in Australia</a><br/></tr> <tr><li><a href="house.html" name="house" target="main">Apartments/Houses/Rent </a><br/></tr> <tr><li><a href="communitee.html" name="israel" target="main">Israel Communitee </a><br/></tr> <tr><li><a href="#main" name="end" >To Top Menu</a><br/> </table>
here is some code (I think it's code you already see) it' my menu
and I want when client over it with mouse it will change it face style,and color
Last edited by peter_budo; Aug 11th, 2009 at 2:21 pm. Reason: Keep It Organized - Avoid using an excessive amount of [bbcode] to alter font styles or to draw more attention to your post.
Here is the code-sample:
Opera-Tested
javascript Syntax (Toggle Plain Text)
<?xml version="1.0" encoding="UTF-8" standalone="no"?> <?xml-stylesheet type="text/css" href="#css_level21" media="all"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head> <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" /> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <meta http-equiv="Content-Style-Type" content="text/css" /> <meta http-equiv="Content-Script-Type" content="text/javascript" /> <title>www.daniweb.com :: DHTML / JavaScript / AJAX</title> <style id="css21" type="text/css" media="all"> /* <![CDATA[ */ a { text-decoration : none; letter-spacing : 1px; color : #00FF00; } ul { list-style : none; margin : 0; width : auto; background-color : transparent !important; } li { list-style : none; margin : 0; width : auto; background-color : #000; padding : .200em .200em .200em .600em; } #table-one { text-align : left; line-height : 1.5; border-collapse : collapse; border : none; margin : 0 auto; background-color : transparent !important; width : 100%; } /* ]]> */ </style> <script type="text/javascript"> // <![CDATA[ var bgcolors = "lime"; var colors = "white"; var setRule = function( e ) { var e = e ? e : window.event; var li = this; li.setAttribute( "style", "background-color : " + bgcolors + "; margin : 0 0 0 12px" + "; color : " + colors + "; padding : .200em .200em .200em .600em; border-top : 1px solid #eee" ); var a = li.firstChild; a.setAttribute( "style", "color : " + colors + "; font-family : 'Bernard MT Condensed', 'Trebuchet MS', Verdana, Helvetica, Arial, sans-serif;" ); this.onmouseout = ( function() { this.removeAttribute("style"); this.firstChild.removeAttribute("style"); } ); (( "cancelBubble" in e ) ? e.cancelBubble = true : e.stopPropagation()); }; window.onload = function( ) { var lists = (( lists = document.getElementById("lists-0")) ? lists : document.all[ "lists-0" ] ); if ( lists.hasChildNodes() ) { var node = lists.childNodes; for ( var x = 0; x < node.length; x++ ) { if ( node[ x ].nodeName.toLowerCase() === "li" ) { if ( window.addEventListener ) { node[ x ].addEventListener( "mouseover", setRule, false ); } else if ( window.attachEvent ) { node[ x ].attachEvent( "onmouseover", setRule ); } else { node[ x ].onmouseover = setRule; } } } } } // ]]> </script> </head> <body id="xhtml11"> <div id="main"> <!-- <form id="menu" name="menu" action="#" onsubmit="return false;"> --> <table id="table-one" frame="void" rules="none" cellpadding="0" cellspacing="0" summary="JavaScript :: Live Demo!"> <tr> <td style="width : 30%; overflow : show"> <ul id="lists-0"> <li><a href="forum.html">Forum About Anything</a></li> <li><a href="links.html">Interesting Links</a></li> <li><a href="price.html">Prices in Australia</a></li> <li><a href="house.html">Apartments/Houses/Rent</a></li> <li><a href="comunitee.html">Israel Communitee</a></li> </ul> </td><td style="width : auto; padding-left : 1em;"><h2>DEMO PAGE</h2></td></tr> </table> </div> </body> </html>
Opera-Tested
Dev.Opera — FOLLOW THE STANDARDS, BREAK THE RULES...
Hi,
here's the demo, you should atleast have IE6 to be able for this to work.
supported in all major browser: ( Firefox/Opera/Chrome/Safari/IE7+)
here's the demo, you should atleast have IE6 to be able for this to work.
javascript Syntax (Toggle Plain Text)
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <meta http-equiv="Content-Style-Type" content="text/css"> <meta http-equiv="Content-Script-Type" content="text/javascript"> <title>http://www.daniweb.com</title> <style type="text/css"> <!-- li a { font-family : Arial, san-serif; color : #FFFFFF; text-decoration : none; letter-spcing : 2px; } li { border : none; background-color : #365d95; padding : .300em .300em .300em 1em; display : block; margin : 0; } ul, li { list-style : none } ul { background-color : #FFFFFF; margin : 0; padding : 0; text-align : left; } li.onHover a { color : #365d95; font-family : "Bernard MT Condensed", "Trebuchet MS"; } li.onHover { border : 1px solid #373832; width : 160px; background-color : #F80; padding : .300em .300em .300em 1em; display : block; margin-left : 1em; } --> </style> <script type="text/javascript"> <!-- var addEvent = function( isEvent, isElement, isFunction, isAttachedTo ) { var eventSupported = (( window.attachEvent ) ? 1 : ( window.addEventListener ? 2 : 3 )) || 0; var installer = { 1 : ( function( obj ) { return obj.attachEvent( "on" + isEvent, isFunction ); } ), 2 : ( function( obj ) { return obj.addEventListener( isEvent, isFunction, false ); } ), 3 : ( function( obj ) { return obj[ "on" + isEvent ] = isFunction; } ) }[ eventSupported ]; if ( eventSupported ) { if ( typeof( isAttachedTo ) !== "undefined" ) { for ( var x = 0; x < isAttachedTo; x++ ) { installer( isElement[ x ] ); } } else { installer( isElement ); } } else { alert("\nunsupported features: please update your browser"); } }; var on_hover = function() { var setClass = document.createAttribute("class"); setClass.nodeValue = "onHover"; if ( this.parentNode.parentNode.id === "demo" ) this.parentNode.setAttributeNode( setClass ); else return false; }; var off_hover = function() { if ( this.parentNode.getAttribute("class")) { this.parentNode.removeAttribute("class"); } }; var installMenu = function() { var menu; if ( document.all ) menu = document.all.tags("a"); else { menu = document.getElementsByTagName("a") } addEvent( "mouseover", menu, on_hover, menu.length ); addEvent( "mouseout", menu, off_hover, menu.length ); }; window.onload = installMenu; // --> </script> </head> <body> <div> <div> <table id="table_0" frame="void" rules="none" border="0" width="100%" cellpadding="0" cellspacing="0"> <tr> <td style="width : 180px; overflow : auto;"><ul id="demo" style="width : 180px; overflow : show;"> <li><a href="#">Sample Link 1</a></li> <li><a href="#">Sample Link 2</a></li> <li><a href="#">Sample Link 3</a></li> <li><a href="#">Sample Link 4</a></li> <li><a href="#">Sample Link 5</a></li> </ul></td> <td></td> </tr> </table> </div> </body> </html>
supported in all major browser: ( Firefox/Opera/Chrome/Safari/IE7+)
the <table> is redundant only <ul> is required
Failure is not an option It's included free, you don't have to do anything to get it
If at first you dont succeed, join the club
Of course its always in the last place you look, you dont keep looking after you find it
Please mark solved problems, solved
If at first you dont succeed, join the club
Of course its always in the last place you look, you dont keep looking after you find it
Please mark solved problems, solved
•
•
•
•
Hi,
here's the demo, you should atleast have IE6 to be able for this to work.
javascript Syntax (Toggle Plain Text)
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <meta http-equiv="Content-Style-Type" content="text/css"> <meta http-equiv="Content-Script-Type" content="text/javascript"> <title>http://www.daniweb.com</title> <style type="text/css"> <!-- li a { font-family : Arial, san-serif; color : #FFFFFF; text-decoration : none; letter-spcing : 2px; } li { border : none; background-color : #365d95; padding : .300em .300em .300em 1em; display : block; margin : 0; } ul, li { list-style : none } ul { background-color : #FFFFFF; margin : 0; padding : 0; text-align : left; } li.onHover a { color : #365d95; font-family : "Bernard MT Condensed", "Trebuchet MS"; } li.onHover { border : 1px solid #373832; width : 160px; background-color : #F80; padding : .300em .300em .300em 1em; display : block; margin-left : 1em; } --> </style> <script type="text/javascript"> <!-- var addEvent = function( isEvent, isElement, isFunction, isAttachedTo ) { var eventSupported = (( window.attachEvent ) ? 1 : ( window.addEventListener ? 2 : 3 )) || 0; var installer = { 1 : ( function( obj ) { return obj.attachEvent( "on" + isEvent, isFunction ); } ), 2 : ( function( obj ) { return obj.addEventListener( isEvent, isFunction, false ); } ), 3 : ( function( obj ) { return obj[ "on" + isEvent ] = isFunction; } ) }[ eventSupported ]; if ( eventSupported ) { if ( typeof( isAttachedTo ) !== "undefined" ) { for ( var x = 0; x < isAttachedTo; x++ ) { installer( isElement[ x ] ); } } else { installer( isElement ); } } else { alert("\nunsupported features: please update your browser"); } }; var on_hover = function() { var setClass = document.createAttribute("class"); setClass.nodeValue = "onHover"; if ( this.parentNode.parentNode.id === "demo" ) this.parentNode.setAttributeNode( setClass ); else return false; }; var off_hover = function() { if ( this.parentNode.getAttribute("class")) { this.parentNode.removeAttribute("class"); } }; var installMenu = function() { var menu; if ( document.all ) menu = document.all.tags("a"); else { menu = document.getElementsByTagName("a") } addEvent( "mouseover", menu, on_hover, menu.length ); addEvent( "mouseout", menu, off_hover, menu.length ); }; window.onload = installMenu; // --> </script> </head> <body> <div> <div> <table id="table_0" frame="void" rules="none" border="0" width="100%" cellpadding="0" cellspacing="0"> <tr> <td style="width : 180px; overflow : auto;"><ul id="demo" style="width : 180px; overflow : show;"> <li><a href="#">Sample Link 1</a></li> <li><a href="#">Sample Link 2</a></li> <li><a href="#">Sample Link 3</a></li> <li><a href="#">Sample Link 4</a></li> <li><a href="#">Sample Link 5</a></li> </ul></td> <td></td> </tr> </table> </div> </body> </html>
supported in all major browser: ( Firefox/Opera/Chrome/Safari/IE7+)
Why not try something efficient, readable and crossbrowser compatible like:
--------------------------- 8< ----------------------------
<body>
<div>
<ul id="demo" style="width : 180px;">
<li><a href="#">Sample Link 1</a></li>
<li><a href="#">Sample Link 2</a></li>
<li><a href="#">Sample Link 3</a></li>
<li><a href="#">Sample Link 4</a></li>
<li><a href="#">Sample Link 5</a></li>
</ul>
</div>
<script type="text/javascript">
document.initMenu = function(id){
var menulist = document.getElementById(id).getElementsByTagName("li")
for (var i=0; i<menulist.length; i++){
menulist[i].onmouseover = function(){this.className='onHover'}
menulist[i].onmouseout = function(){this.className=''} } }
document.initMenu("demo")
</script>
</body>
</html>![]() |
Similar Threads
- Dialog color (C++)
- I need help with a save function in my game. (C++)
- Help! XP Pro Taskbar Color Change (Windows NT / 2000 / XP)
- Tutorial: Create a cross-browser compatible, single-level, drop-down menu (Site Layout and Usability)
- HTML 3.2 table background color (HTML and CSS)
- active row (ASP.NET)
- customized right-click menu based on id (JavaScript / DHTML / AJAX)
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: Auto select current day/month in a dropdown
- Next Thread: Print Page
| Thread Tools | Search this Thread |
Tag cloud for JavaScript / DHTML / AJAX
ajax ajaxcode ajaxhelp ajaxjspservlets animate api automatically beta blackjack box browser bug calendar captchaformproblem card checkbox child class close cookies createrange() cursor dependent disablefirebug dom dropdown editor element engine events explorer ext file firehose flash form forms game google gwt gxt hiddenvalue highlightedword html htmlform ie8 iframe image() images internet java javascript jawascriptruntimeerror jquery jsf jsfile jump libcurl math matrixcaptcha media microsoft mimic object onmouseoutdivproblem onreadystatechange parent pdf php player post progressbar rated regex runtime scroll search security session shopping size software sql star stars stretch synchronous text textarea twitter unicode validation web website window windowofwords windowsxp wysiwyg xml \n






