kan der laves en "time out" ??
fik denne dropdown-menu af t_kriss, og det er fint nok, men kan man ikke gøre sådan at hvis musen gøres over og væk igen så forsvinder dropdown'en ?? nu skal man klikke uden for menuen for at få det væk !!kode:
<HTML><HEAD>
<script language="JavaScript" type="text/javascript">
// Copyright © 2000 by Apple Computer, Inc., All Rights Reserved.
//
// You may incorporate this Apple sample code into your own code
// without restriction. This Apple sample code has been provided "AS IS"
// and the responsibility for its operation is yours. You may redistribute
// this code, but you are not permitted to redistribute it as
// "Apple sample code" after having made changes.
//
// ************************
// layer utility routines *
// ************************
function getStyleObject(objectId) {
// cross-browser function to get an object's style object given its id
if(document.getElementById && document.getElementById(objectId)) {
// W3C DOM
return document.getElementById(objectId).style;
} else if (document.all && document.all(objectId)) {
// MSIE 4 DOM
return document.all(objectId).style;
} else if (document.layers && document.layers[objectId]) {
// NN 4 DOM.. note: this won't find nested layers
return document.layers[objectId];
} else {
return false;
}
} // getStyleObject
function changeObjectVisibility(objectId, newVisibility) {
// get a reference to the cross-browser style object and make sure the object exists
var styleObject = getStyleObject(objectId);
if(styleObject) {
styleObject.visibility = newVisibility;
return true;
} else {
// we couldn't find the object, so we can't change its visibility
return false;
}
} // changeObjectVisibility
function moveObject(objectId, newXCoordinate, newYCoordinate) {
// get a reference to the cross-browser style object and make sure the object exists
var styleObject = getStyleObject(objectId);
if(styleObject) {
styleObject.left = newXCoordinate;
styleObject.top = newYCoordinate;
return true;
} else {
// we couldn't find the object, so we can't very well move it
return false;
}
} // moveObject
<!--
// ********************************
// application-specific functions *
// ********************************
function showMenu(menuNumber, eventObj) {
// alert(eventObj);
hideAllMenus();
var menuId = 'menu' + menuNumber;
if(changeObjectVisibility(menuId, 'visible')) {
var menuTitle = getStyleObject('menuTitle' + menuNumber);
menuTitle.backgroundColor = '#ff9900';
eventObj.cancelBubble = true;
return true;
} else {
return false;
}
}
var numMenus = 2;
function hideAllMenus() {
for(counter = 1; counter <= numMenus; counter++) {
changeObjectVisibility('menu' + counter, 'hidden');
var menuTitle = getStyleObject('menuTitle' + counter);
menuTitle.backgroundColor = '#000000';
}
}
document.onclick = hideAllMenus;
// -->
</SCRIPT>
<STYLE>
.menu { POSITION: absolute; VISIBILITY: hidden; BACKGROUND-COLOR: #999999; LAYER-BACKGROUND-COLOR: #999999; BORDER-LEFT: 1px solid black; BORDER-TOP: 1px solid black; BORDER-BOTTOM: 3px solid black; BORDER-RIGHT: 3px solid black; PADDING: 3px; z-index: 10; width: 100 }
.menuTitle { width: 35; BORDER-LEFT: 1px solid black; BORDER-TOP: 1px solid black; BORDER-BOTTOM: 1px solid black; BORDER-RIGHT: 1px solid black; PADDING: 3px; BACKGROUND-COLOR: #000000 }
.menuBarLink { text-decoration: none; font-style: bold; color: #ffffff; font-family: helvetica,arial; outline: none }
.menuLink { text-decoration: none; font-style: bold; color: #000000; outline: none }
a:hover.menuLink { text-decoration: none; font-style: bold; color: #ffffff }
#menuTitle1 { position: absolute; left: 10; top: 10; font-size: 14px }
#menuTitle2 { position: absolute; left: 50; top: 10; font-size: 14px }
#menu1 { position: absolute; left: 13; top: 29; font-size: 14px }
#menu2 { position: absolute; left: 53; top: 29; font-size: 14px }
#contentDiv { position: absolute; left: 10; top: 40; font-size: 14px }
</STYLE>
<BODY bgcolor="white">
<div id=menu1 class=menu onclick=event.cancelBubble = true;"><a href="#" class=menuLink>Home page</a><br>
<a href="#" class=menuLink>Fun</a><br>
<a href="#" class=menuLink>Serious</a></div>
<div id=menu2 class=menu onclick="event.cancelBubble = true;"><a href="#" class=menuLink>FAQ</a><br>
<a href="#" class=menuLink>Contact</a><br>
<a href="#" class=menuLink>About...</a></div>
<div id=menuTitle1 class=menuTitle><a href="http://www.giantant.com/" onmouseover="return !showMenu('1', event);" class=menuBarLink>Go</a></div>
<div id=menuTitle2 class=menuTitle><a href="http://www.giantant.com/" onmouseover="return !showMenu('2', event);" class=menuBarLink>Help</a></div>
<div id=contentDiv>
Select an option from the menu above.
</div>
</BODY></HTML>
