Prøv det her:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"
http://www.w3.org/TR/html4/loose.dtd"><html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>TITLE</title>
<style type="text/css">
body, html {
height: 100%;
margin: 0;
padding: 0;
}
#menu {
position: relative;
width: 120px;
height: 200px;
border: 1px solid red;
margin: 40px;
}
#menu a, #menu a:visited {
width: 100px;
padding: 1px 10px;
font: 12px tahoma, sans serif;
text-decoration: none;
color: #666666;
display: block;
}
#menu a:hover {
text-decoration: none;
color: #666666;
}
#popMenu {
position: absolute;
width: 120px;
left: 5px;
border: 1px solid red;
display: none;
z-index: 2;
}
#popMenu a, #popMenu a:visited {
width: 100px;
padding: 1px 10px;
font: 12px tahoma, sans serif;
text-decoration: none;
background-color: yellow;
color: red;
display: block;
}
#popMenu a:hover {
text-decoration: none;
background-color: red;
color: yellow;
}
</style>
<script type="text/JavaScript">
function menDown(e) {
var css = oPopMenu.style;
oPopMenu.setAttribute("activeID", this.id);
css.top = (this.offsetTop+this.offsetHeight) + "px";
css.display = "block";
if (!window.event) {
e.cancelBubble = true;
e.preventDefault();
e.stopPropagation();
}
}
function mUp(e) {
var id, srcElm = window.event? window.event.srcElement : e.target;
if (srcElm.id && srcElm.id.indexOf("popLink_")!=-1) {
id = oPopMenu.getAttribute("activeID");
switch ( parseInt(srcElm.id.split("popLink_")[1]) ) {
case 0:
alert("Du klikkede på nummer 0.\nDet aktive menulinks id: " + id);
break;
case 1:
alert("Du klikkede på nummer 1.\nDet aktive menulinks id: " + id);
break;
case 2:
alert("Du klikkede på nummer 2.\nDet aktive menulinks id: " + id);
break;
case 3:
alert("Du klikkede på nummer 3.\nDet aktive menulinks id: " + id);
break;
}
}
oPopMenu.style.display = "none";
}
var oPopMenu = null;
window.onload = function() {
var aA = document.getElementById("menu").getElementsByTagName("a");
oPopMenu = document.getElementById("popMenu");
for (var i=0,j=aA.length; i<j; i++) {
aA[i].ondragstart = function(){return false};
aA[i].onmousedown = menDown;
}
document.onmouseup = mUp;
}
</script>
</head>
<body>
<div id="menu">
<a id="link_0" href="#">Link 0</a>
<a id="link_1" href="#">Link 1</a>
<a id="link_2" href="#">Link 2</a>
<a id="link_3" href="#">Link 3</a>
<div id="popMenu">
<a id="popLink_0" href="#">PopLink 0</a>
<a id="popLink_1" href="#">PopLink 1</a>
<a id="popLink_2" href="#">PopLink 2</a>
<a id="popLink_3" href="#">PopLink 3</a>
</div>
</div>
</body>
</html>