Pour ajouter un menu défilant dans une page Web :

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script language="javascript" type="text/javascript">
var active;
function init(){
var myElement = document.getElementById(1);
myElement.style.display = "block";
active=myElement;
}

function swapLayer(objMenu) {
var myElement = document.getElementById(objMenu);
if (myElement.style.display == "none") {

active.style.display = "none";
myElement.style.display = "block";
active =myElement;
}
else {
myElement.style.display = "none";
}
}
</script>

</head>
<body onload="init();">
<div>
    <a href="javascript:void(0);" onclick="swapLayer(0);"> Menu 1</a>
    <div id="0" style="margin: 5px; display: none;">Sous Menu 1<br /></div>
</div>
<div>
    <a href="javascript:void(0);" onclick="swapLayer(1);"> Menu 2</a>
    <div id="1" style="margin: 5px; display: none;">Sous Menu 2</div>
</div>
</body>
</html>
 
Tags:
Répondre