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 60 61 62
|
<html>
<head>
<style type="text/css">
#part{
display:block;
width:300px;
height:300px;
background-color:#CCCC33;
}
#corp{
display:none;
width:300px;
height:300px;
background-color:#0099FF;
}
#inst{
display:none;
width:300px;
height:300px;
background-color:#66CCFF;
}
</style>
<script type="text/javascript">
window.onload = function() {
document.getId = document.getElementById;
var i,
j,
onglets = document.getId("onglets"),
content = document.getId("content"),
switchers = onglets.getElementsByTagName('a');
boxes = content.getElementsByTagName('div');
for(i=0;i<switchers.length;i+=1) {
switchers[i].onclick = function(e) { //Au click sur un lien...
e = e || window.event;
for(j=0;j<boxes.length;j+=1){
boxes[j].style.display='none'; //On cache toutes les div
}
document.getId(this.hash.substring(1)).style.display='block'; //On affiche celle qui correspond au # lien cliqué, on fait ainsi la même chose qu'avec l'ancre
(e.preventDefault) ? e.preventDefault() : e.returnValue=false ; //On evite le saut vers la div en question
}
}
}
</script>
</head>
<body>
<div id="onglets">
<div><a href="#part"> Tarifs particuliers</a></div>
<div><a href="#corp"> Tarifs Entreprises</a></div>
<div><a href="#inst"> Tarifs Education</a></div>
</div>
<div id="content">
<div id="part"> DIV PARTICULIERS </div>
<div id="corp"> DIV CORPORATE </div>
<div id="inst"> DIV INSTITUTIONS </div>
</div>
</body>
</html> |
Partager