程序代码:
<script type="text/javascript"> var menu1=[ {name:'测试1-1',add:'1-1.html',target:'main'}, {name:'测试1-2',add:'1-2.html',target:'main'}, {name:'测试1-3',add:'3-3.html',target:'main'}]; function show(obj){ var divMenu=document.getElementById("menu"); if(obj!=null){ divMenu.style.top=(parseInt(obj.style.top.substring(0,obj.style.top.length))+18)+"px"; divMenu.style.left=obj.style.left; var menuid=obj.id; var menu=eval(menuid); var divValue="<div style=\"z-index:100\">"; for(i=0;i<menu.length;i++){divValue+="<div><a href='"+menu[i].add+"' target='"+menu[i].target+"'>"+menu[i].name+"<\/a><\/div>";} divValue+="<\/div>"; divMenu.innerHTML=divValue; divMenu.onmouseout = function(){if(window.event.toElement.tagName !='A')divMenu.style.display="none";} divMenu.style.display="block"; }else{divMenu.style.display="none";} } </script> <style type="text/css"> a{color:#FF3399; text-decoration:none;} a:hover{color:blue; text-decoration:none;} </style> <div onmouseout="if (window.event.toElement.tagName !='A') {menu.style.display='none';}"> <div id="menu1" onmouseover="show(this)" style="position:absolute; cursor:hand; border:1px solid skyblue; left:100px; top:20px;">测试测试</div> </div> <div id="menu" style="border:1px solid skyblue; position:absolute; display:none; z-index:99"></div>