|
tableless cross-browser menu thing
[
bamboo
]
Webdesigning me? Nah... Just the old javascript/CSS/XHTML reality check every now and then.
1:<html> 2:<head> 3:<style> 4:.body 5:{ 6: font-family: verdana; 7: font-size: 10pt; 8:} 9: 10:.menuItem, .menuItemHover 11:{ 12: background-color: blue; 13: font-weight: bold; 14: padding: 5px; 15: color: white; 16: display: inline; 17: cursor: pointer; 18:} 19: 20:.menuItemHover 21:{ 22: background-color: lightblue; 23:} 24:</style> 25: 26:<script language="javascript"> 27:document.onmouseover = function(ev) 28:{ 29: var element = getEventTarget(ev); 30: if ("menuItem" == element.className) 31: { 32: element.className = "menuItemHover"; 33: } 34:} 35: 36:document.onmouseout = function(ev) 37:{ 38: var element = getEventTarget(ev); 39: if ("menuItemHover" == element.className) 40: { 41: element.className = "menuItem"; 42: } 43:} 44: 45:function getEventTarget(ev) 46:{ 47: return (ev && ev.target) || window.event.srcElement; 48:} 49: 50:</script> 51:</head> 52:<body> 53: 54:<div id="menuBar"> 55:<div class="menuItem"> 56:<img src="images/arrow.gif" /> 57:About US 58:</div> 59:<div class="menuItem"> 60:<img src="images/arrow.gif" /> 61:Products 62:</div> 63:</div> 64: 65: 66:</body> 67:</html> The same old few conclusions:
vlw fei! --Leo, October 5, 2004 06:11 PM
IMHO the javascript is completely unnecessary. .menuItem:hover Not sure about the compatibility, but works fine on IE and Firefox. Cheers! --hammett, October 7, 2004 11:21 PM
Hmmm... I recall trying that. Wonder what I did wrong then... Thanks! Good to know it works. --bamboo, October 7, 2004 11:25 PM
Post a comment
|