begin process at 2012 05 28 11:23:13
  Trouver un code source :
 
dans
 
Accueil > 

Code

 > 

Trucs & Astuces

 > MENU DHTML : PAS BIEN SORCIER MAIS PRATIQUE A SAVOIR

MENU DHTML : PAS BIEN SORCIER MAIS PRATIQUE A SAVOIR


 Information sur la source

Note :
8 / 10 - par 7 personnes
8,00 / 10

  • 1

  • 2

  • 3

  • 4

  • 5

  • 6

  • 7

  • 8

  • 9

  • 10
Catégorie :Trucs & Astuces Niveau :Débutant Date de création :01/05/2003 Date de mise à jour :01/05/2003 18:20:51 Vu :18 343

Auteur : lumesh

Ecrire un message privé
Site perso
Commentaire sur cette source (4)
Ajouter un commentaire et/ou une note

 Description

Un petit menu tout simple avec des sous menu.
pour lexemple j'ai mis k1 seul sous nvo de menu mais plusieurs ss nvo sont tre facilement realisable.

Source

  • <html>
  • <head>
  • <title>Menu dHTML</title>
  • <meta name="author" content="Christophe">
  • <SCRIPT language=JScript>
  • function ShowHide(Div) {
  • if (Div.style.display=='none') {
  • Div.style.display='InLine';
  • }
  • else {
  • Div.style.display='none';
  • }
  • }
  • </SCRIPT>
  • </head>
  • <body bgcolor="white" text="black" link="blue" vlink="purple" alink="red">
  • <table style="border-top-width:1px; border-right-width:1px; border-bottom-width:0px; border-left-width:1px; border-color:rgb(153,153,153); border-top-style:solid; border-right-style:solid; border-bottom-style:none; border-left-style:solid;" cellpadding="5" cellspacing="0" bgcolor="#CCCCCC" bordercolordark="white" bordercolorlight="black">
  • <tr>
  • <td width="150">
  • <p style="line-height:100%; margin-top:0; margin-bottom:0;">titre
  • <a href="#" OnClick="javascript: ShowHide(menu1);">menu 1</a></p>
  • </td>
  • </tr>
  • </table>
  • <DIV id='menu1' style=display=InLine;>
  • <table style="line-height:100%; margin-top:0; margin-bottom:0; border-top-width:1px; border-right-width:1px; border-bottom-width:0px; border-left-width:1px; border-color:rgb(153,153,153); border-top-style:solid; border-right-style:solid; border-bottom-style:none; border-left-style:solid;" cellpadding="5" cellspacing="0" bgcolor="#F9F9F9">
  • <tr>
  • <td width="150" style="border-bottom-width:1px; border-bottom-color:rgb(153,153,153); border-bottom-style:solid;">
  • <p style="line-height:100%; margin-top:0; margin-bottom:0; margin-left:20;">sous menu 1</p>
  • </td>
  • </tr>
  • <tr>
  • <td width="150" style="border-bottom-width:1px; border-bottom-color:rgb(153,153,153); border-bottom-style:solid;">
  • <p style="line-height:100%; margin-top:0; margin-bottom:0; margin-left:20;">sous menu 2</p>
  • </td>
  • </tr>
  • <tr>
  • <td width="150">
  • <p style="line-height:100%; margin-top:0; margin-bottom:0; margin-left:20;">sous menu 3</p>
  • </td>
  • </tr>
  • </table>
  • </div>
  • <table style="border-width:1px; border-color:rgb(153,153,153); border-style:solid;" cellpadding="5" cellspacing="0" bgcolor="#CCCCCC" bordercolordark="white" bordercolorlight="black">
  • <tr>
  • <td width="150">
  • <p style="line-height:100%; margin-top:0; margin-bottom:0;">titre
  • <a href="#" OnClick="javascript: ShowHide(menu2);">menu 2</a></p>
  • </td>
  • </tr>
  • </table>
  • <DIV id='menu2' style=display=none;>
  • <table style="line-height:100%; margin-top:0; margin-bottom:0; border-top-width:0px; border-right-width:1px; border-bottom-width:1px; border-left-width:1px; border-color:rgb(153,153,153); border-top-style:none; border-right-style:solid; border-bottom-style:solid; border-left-style:solid;" cellpadding="5" cellspacing="0" bgcolor="#F9F9F9">
  • <tr>
  • <td width="150" style="border-bottom-width:1px; border-bottom-color:rgb(153,153,153); border-bottom-style:solid;">
  • <p style="line-height:100%; margin-top:0; margin-bottom:0; margin-left:20;">sous menu 1</p>
  • </td>
  • </tr>
  • <tr>
  • <td width="150" style="border-bottom-width:1px; border-bottom-color:rgb(153,153,153); border-bottom-style:solid;">
  • <p style="line-height:100%; margin-top:0; margin-bottom:0; margin-left:20;">sous menu 2</p>
  • </td>
  • </tr>
  • <tr>
  • <td width="150">
  • <p style="line-height:100%; margin-top:0; margin-bottom:0; margin-left:20;">sous menu 3</p>
  • </td>
  • </tr>
  • </table>
  • </div>
  • <table style="border-top-width:0px; border-right-width:1px; border-bottom-width:1px; border-left-width:1px; border-color:rgb(153,153,153); border-top-style:none; border-right-style:solid; border-bottom-style:solid; border-left-style:solid;" cellpadding="5" cellspacing="0" bgcolor="#CCCCCC" bordercolordark="white" bordercolorlight="black">
  • <tr>
  • <td width="150">
  • <p style="line-height:100%; margin-top:0; margin-bottom:0;">titre
  • <a href="#" OnClick="javascript: ShowHide(menu3);">menu 3</a></p>
  • </td>
  • </tr>
  • </table>
  • <DIV id='menu3' style=display=none;>
  • <table style="line-height:100%; margin-top:0; margin-bottom:0; border-top-width:0px; border-right-width:1px; border-bottom-width:1px; border-left-width:1px; border-color:rgb(153,153,153); border-top-style:none; border-right-style:solid; border-bottom-style:solid; border-left-style:solid;" cellpadding="5" cellspacing="0" bgcolor="#F9F9F9">
  • <tr>
  • <td width="150" style="border-bottom-width:1px; border-bottom-color:rgb(153,153,153); border-bottom-style:solid;">
  • <p style="line-height:100%; margin-top:0; margin-bottom:0; margin-left:20;">sous menu 1</p>
  • </td>
  • </tr>
  • <tr>
  • <td width="150" style="border-bottom-width:1px; border-bottom-color:rgb(153,153,153); border-bottom-style:solid;">
  • <p style="line-height:100%; margin-top:0; margin-bottom:0; margin-left:20;">sous menu 2</p>
  • </td>
  • </tr>
  • <tr>
  • <td width="150">
  • <p style="line-height:100%; margin-top:0; margin-bottom:0; margin-left:20;">sous menu 3</p>
  • </td>
  • </tr>
  • </table>
  • </div>
  • </body>
  • </html>
<html>

<head>
<title>Menu dHTML</title>
<meta name="author" content="Christophe">

<SCRIPT language=JScript>
 function ShowHide(Div) {
   if (Div.style.display=='none') {
     Div.style.display='InLine';
    } 
    else {
     Div.style.display='none';
    }
  }
</SCRIPT>

</head>

<body bgcolor="white" text="black" link="blue" vlink="purple" alink="red">
<table style="border-top-width:1px; border-right-width:1px; border-bottom-width:0px; border-left-width:1px; border-color:rgb(153,153,153); border-top-style:solid; border-right-style:solid; border-bottom-style:none; border-left-style:solid;" cellpadding="5" cellspacing="0" bgcolor="#CCCCCC" bordercolordark="white" bordercolorlight="black">
    <tr>
        <td width="150">
            <p style="line-height:100%; margin-top:0; margin-bottom:0;">titre 
            <a href="#" OnClick="javascript: ShowHide(menu1);">menu 1</a></p>
        </td>
    </tr>
</table>

<DIV id='menu1' style=display=InLine;>

<table style="line-height:100%; margin-top:0; margin-bottom:0; border-top-width:1px; border-right-width:1px; border-bottom-width:0px; border-left-width:1px; border-color:rgb(153,153,153); border-top-style:solid; border-right-style:solid; border-bottom-style:none; border-left-style:solid;" cellpadding="5" cellspacing="0" bgcolor="#F9F9F9">
    <tr>
        <td width="150" style="border-bottom-width:1px; border-bottom-color:rgb(153,153,153); border-bottom-style:solid;">
            <p style="line-height:100%; margin-top:0; margin-bottom:0; margin-left:20;">sous menu 1</p>
        </td>
    </tr>
    <tr>
        <td width="150" style="border-bottom-width:1px; border-bottom-color:rgb(153,153,153); border-bottom-style:solid;">
            <p style="line-height:100%; margin-top:0; margin-bottom:0; margin-left:20;">sous menu 2</p>
        </td>
    </tr>
    <tr>
        <td width="150">
            <p style="line-height:100%; margin-top:0; margin-bottom:0; margin-left:20;">sous menu 3</p>
        </td>
    </tr>
</table>

</div>

<table style="border-width:1px; border-color:rgb(153,153,153); border-style:solid;" cellpadding="5" cellspacing="0" bgcolor="#CCCCCC" bordercolordark="white" bordercolorlight="black">
    <tr>
        <td width="150">
            <p style="line-height:100%; margin-top:0; margin-bottom:0;">titre 
            <a href="#" OnClick="javascript: ShowHide(menu2);">menu 2</a></p>
        </td>
    </tr>
</table>

<DIV id='menu2' style=display=none;>

<table style="line-height:100%; margin-top:0; margin-bottom:0; border-top-width:0px; border-right-width:1px; border-bottom-width:1px; border-left-width:1px; border-color:rgb(153,153,153); border-top-style:none; border-right-style:solid; border-bottom-style:solid; border-left-style:solid;" cellpadding="5" cellspacing="0" bgcolor="#F9F9F9">
    <tr>
        <td width="150" style="border-bottom-width:1px; border-bottom-color:rgb(153,153,153); border-bottom-style:solid;">
            <p style="line-height:100%; margin-top:0; margin-bottom:0; margin-left:20;">sous menu 1</p>
        </td>
    </tr>
    <tr>
        <td width="150" style="border-bottom-width:1px; border-bottom-color:rgb(153,153,153); border-bottom-style:solid;">
            <p style="line-height:100%; margin-top:0; margin-bottom:0; margin-left:20;">sous menu 2</p>
        </td>
    </tr>
    <tr>
        <td width="150">
            <p style="line-height:100%; margin-top:0; margin-bottom:0; margin-left:20;">sous menu 3</p>
        </td>
    </tr>
</table>

</div>

<table style="border-top-width:0px; border-right-width:1px; border-bottom-width:1px; border-left-width:1px; border-color:rgb(153,153,153); border-top-style:none; border-right-style:solid; border-bottom-style:solid; border-left-style:solid;" cellpadding="5" cellspacing="0" bgcolor="#CCCCCC" bordercolordark="white" bordercolorlight="black">
    <tr>
        <td width="150">
            <p style="line-height:100%; margin-top:0; margin-bottom:0;">titre 
            <a href="#" OnClick="javascript: ShowHide(menu3);">menu 3</a></p>
        </td>
    </tr>
</table>

<DIV id='menu3' style=display=none;>

<table style="line-height:100%; margin-top:0; margin-bottom:0; border-top-width:0px; border-right-width:1px; border-bottom-width:1px; border-left-width:1px; border-color:rgb(153,153,153); border-top-style:none; border-right-style:solid; border-bottom-style:solid; border-left-style:solid;" cellpadding="5" cellspacing="0" bgcolor="#F9F9F9">
    <tr>
        <td width="150" style="border-bottom-width:1px; border-bottom-color:rgb(153,153,153); border-bottom-style:solid;">
            <p style="line-height:100%; margin-top:0; margin-bottom:0; margin-left:20;">sous menu 1</p>
        </td>
    </tr>
    <tr>
        <td width="150" style="border-bottom-width:1px; border-bottom-color:rgb(153,153,153); border-bottom-style:solid;">
            <p style="line-height:100%; margin-top:0; margin-bottom:0; margin-left:20;">sous menu 2</p>
        </td>
    </tr>
    <tr>
        <td width="150">
            <p style="line-height:100%; margin-top:0; margin-bottom:0; margin-left:20;">sous menu 3</p>
        </td>
    </tr>
</table>

</div>

</body>

</html>


 Conclusion

en gros c simple:

entre les balises &lt;head&gt; &lt;/head&gt; il y a une ptite fonction JS.

pour afficher ou cacher un element il faut tout simplement utiliser des balise DIV

exemple:
vous avez un lien et quand celui ci est clické vous voulez faire apparraitre une description:
alors faites:

&lt;html&gt;
&lt;head&gt;
&lt;SCRIPT language=JScript&gt;
function ShowHide(Div) {
   if (Div.style.display=='none') {
     Div.style.display='InLine';
    }
    else {
     Div.style.display='none';
    }
  }
&lt;/SCRIPT&gt;
&lt;/head&gt;
&lt;body&gt;

&lt; a href="#" OnMouseOver="javascript: ShowHide(lien);" OnMouseOut="javascript: ShowHide(lien);"&gt;&lt;font size="3" face="Verdana,Arial" color="#990000"&gt;le lien a decrire&lt;/font&gt;&lt;/a&gt;&lt;font color="#990000"&gt;
&lt;/font&gt;&lt;div id="lien" style=display=none;&gt;
&lt;font size="2" face="Verdana,Arial" color="#9999FF"&gt;&nbsp;(ici la description du lien)
&lt;/font&gt;&lt;/div&gt;

&lt;/body&gt;
&lt ;/html&gt;

et voila c'est tout con !
en plus on peut faire pas mal de choses !


 Sources du même auteur

Source avec Zip DIV: VRAI FAUSSE FENETRE
Source avec Zip DIV/LAYER MOBILE COMME UNE FENETRE

 Sources de la même categorie

PARSER LES CARACTÈRES HTML D'UNE STRING par jdmcreator
CONSTRUCTION D'UNE TABLE TRIABLE À PARTIR D'UN TABLEAU 2D par phm
Source avec Zip Source avec une capture SUBDIVISER LE RÉSULTAT D'UNE RECHERCHE EN PAGES par kimmp
Source avec Zip TIMER : SETTIMEOUT & SETINTERVAL AMÉLIORÉS par jdmcreator
Source avec Zip Source avec une capture ONGLETS ET CHANGEMENT INSTANTANÉ DE LA LANGUE par william voirol

Commentaires et avis

Commentaire de Mumuri le 31/05/2003 13:27:58

En effet, je te félicite, j'avais moi méme utilisé le principer pour faire afficher des aides sur mon site. ON peut faire plein de trucs avec ca

Commentaire de romalafrite le 09/04/2004 19:25:09

Enfin je le trouve. Au milieu de tous les scripts compliqués et finalement inutiles, on ne trouve plus les scripts de base, il était important d'en mettre un comme celui ci ici.

Rien à redire, sauf que ça serait bien de le valider XHTML. (fermer les balises, mettre des guillemets autour des attributs, etc.) Mais cela dit, c'est pas l'objet du lieu.

9/10

Commentaire de jnbrunet le 23/09/2005 00:38:11

vraiment bien...je débute et j'avais justement besoin d'un code simple comme celui là....vrm merci


Jn
10/10

Commentaire de badams6262 le 10/01/2007 17:21:22

Nickel !!!!
Thanks à l'auteur !!!

BRAVO !! BRAVO !!!!

 Ajouter un commentaire




Nos sponsors


Sondage...

Comparez les prix

CalendriCode

Mai 2012
LMMJVSD
 123456
78910111213
14151617181920
21222324252627
28293031   

Consulter la suite du CalendriCode

Photothèque

A découvrir



 
Développement réalisé par Nicolas SOREL (Nix) avec l'aide de : Cyril DURAND et Emmanuel (EBArtSoft), Merci à Vincent pour ses précieux conseils.
CodeS-SourceS.com© Toute reproduction même partielle est interdite sauf accord écrit du Webmaster
CodeS-SourceS.com© est une marque déposée tous droits réservés

Google Coop CodeS-SourceS Google Coop CodeS-SourceS
Temps d'éxécution de la page : 0,515 sec (3)

Nous contacter | Annoncer sur CodeS-SourceS | Mentions légales