1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
| <!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>
<title>afficher des div</title>
<meta http-equiv="Content-type" content="text/html; charset=UTF-8" />
<style type="text/css">
* {margin:0;padding:0;}
body {margin:10px;background:#000;color:#ddd;font-size:1em;font-family:Helvetica, Arial, sans-serif;}
.conteneur {background:#111;}
.zone {width:120px;height:640px;}
.gauche {float:left;}
.droit {float:right;}
#fond {width:100%;}
#gauche {display:none;background:#222;}
#droit {display:none;background:#333;}
</style>
</head>
<body>
<div id="fond">
<div class="conteneur zone gauche">
<div id="gauche" class="zone"></div>
</div>
<div class="conteneur zone droit">
<div id="droit" class="zone"></div>
</div>
</div>
<script type="text/javascript">
<!--
var FC = {
Evenement: {
evenements: [],
ajouter: function(elm, evt, fn) {
var fni = function(e) { // prévient le comportement par défaut
if (fn(e)===false) { // false explicitement car peut être undefined en cas de délégation d'évènement
if (e.preventDefault) { e.preventDefault(); }
else { e.returnValue = false; }
}
};
if (document.addEventListener) { elm.addEventListener(evt, fni, false); }
else if (document.attachEvent) { elm.attachEvent("on" + evt, fni); }
FC.Evenement.evenements.push([elm, evt, fni]);
}
}
}
FC.Evenement.ajouter(document, "mouseover", function(e) {
var elm = e.target || event.srcElement;
if (elm.className.indexOf("conteneur")>-1) {
if (elm.className.indexOf("gauche")>-1) {
enfant = document.getElementById("gauche");
} else if (elm.className.indexOf("droit")>-1) {
enfant = document.getElementById("droit");
}
enfant.style.display="block";
}
});
//-->
</script>
</body>
</html> |
Partager