højremenu endnu engang
Se følgende script:I funktionen clickMenu() bliver id'et fra displayMenu overført. Dvs. ID'et fra de 2 <tr> i tabellen.
Hvorfor kan jeg godt lave om på className ved at skrive :
document.all.a1.className = ''; (a1 er id'et på <tr>)
men ikke når den bruger idtr ???
Det er jo samme id ?!?!?
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<link rel="stylesheet" type="text/css" href="/wiz.css">
<STYLE>
.menuItem {font-family:tahoma, sans-serif;font-size:10pt;width:120;padding-left:10;
background-Color:menu;color:black}
.highlightItem {font-family:tahoma, sans-serif;font-size:10pt;width:120;padding-left:10;
background-Color:highlight;color:white}
.clickableSpan {padding:4;width:500;background-Color:blue;color:white;border:5px gray solid}
</STYLE>
<SCRIPT type="text/javascript">
function displayMenu(CB) {
var styleclass = CB.className;
CB.className='H';
clickMenu.RowId = CB.id;
whichDiv=event.srcElement;
menu1.style.leftPos+=0;
menu1.style.posLeft=event.clientX;
menu1.style.posTop=event.clientY - 0;
menu1.style.display="";
menu1.setCapture();
}
function switchMenu() {
el=event.srcElement;
if (el.className=="menuItem") {
el.className="highlightItem";
} else if (el.className=="highlightItem") {
el.className="menuItem";
}
}
function clickMenu(CBS) {
var idtr = clickMenu.RowId;
document.all.idtr.className = '';
menu1.releaseCapture();
menu1.style.display="none";
el=event.srcElement;
if (el.id=="mnuHist") {
// FUNKTION
} else if (el.id=="mnuEdit") {
// FUNKTION
} else if (el.id=="mnuUpdate") {
// FUNKTION
} else if (el.id=="mnuRead") {
// FUNKTION
}
}
//-->
</SCRIPT>
</head>
<title>TEST</title>
<body>
<table width="80%" align="center" border="1">
<tr oncontextmenu="displayMenu(this); return false;" id="a1">
<td width="25%"><font color=black>test</font></td>
<td width="25%"><font color=black>test2</font></td>
<td width="25%"> </td>
<td width="25%"> </td>
</tr>
<tr oncontextmenu="displayMenu(this); return false;" id="a2">
<td width="25%"><font color=black>test3</font></td>
<td width="25%"><font color=black>test4</font></td>
<td width="25%"> </td>
<td width="25%"> </td>
</tr>
</table>
<div id=menu1 onclick="clickMenu()" onmouseover="switchMenu()" onmouseout="switchMenu()" style="position:absolute;display:none;width:128;background-Color:menu; border: outset 2px black">
<div style="background: #C4D7E6; width: 129px; border-bottom: 1px solid black;" onMouseover="" OnMouseOut="" class="menuItem" id=nothing><b>DOKUMENTMENU</b></div>
<div style="width: 129px; border-bottom: 1px solid #cccccc" class="menuItem" id=mnuEdit><img src="/images/refresh_icon.gif"> Rediger </div>
<div style="width: 129px; border-bottom: 1px solid #cccccc" class="menuItem" id=mnuUpdate><img src="/images/refresh_icon.gif"> Opdater</div>
<div style="width: 129px; border-bottom: 1px solid #cccccc" class="menuItem" id=mnuDelete><img src="/images/refresh_icon.gif"> Slet</div>
<div style="width: 129px; border-bottom: 1px solid #cccccc" class="menuItem" id=mnuHist><img src="/images/refresh_icon.gif"> Historik</div>
<div style="width: 129px; border-bottom: 1px solid #cccccc" class="menuItem" id=mnuRead><img src="/images/refresh_icon.gif"> Læs</div>
</div>
</body>
</html>