<html> <head> <title>Image</title> <style> .boxDialog { clear: both; background-color: buttonface; border: 0px; margin: 5px; font-family: arial; font-size: 11px } .boxGroup1 { float: left; text-align: left; width: 345px; padding-left: 0px; padding-right: 10px; padding-bottom: 10px; } .boxLabel { width: 70px; padding-left: 10px; padding-right: 5px; padding-top: 15px;} .boxList { width: 70px; height: 20px; font-size: 10px; } .boxText { width: 255px; height: 20px; font-size: 10px; } .boxGroup2 { float: left; text-align: center; width: 90px; } .boxButton { width: 80px; margin-top: 6px; } </style> </head> <body class="boxDialog" onload="InitForm();" onkeypress="CheckKey();"> <form name="frmLink" id="frmLink"> <fieldset class="boxGroup1"> <legend>Informations sur l'image</legend> <label class="boxLabel" accesskey="U" for="txtUrl"><u>U</u>RL</label> <input class="boxText" name="txtUrl" value="" size="40" maxlength="255" id="txtUrl" /> <br /> <label class="boxLabel" accesskey="L" for="txtTitre"><u>L</u>égende</label> <input class="boxText" name="txtTitre" value="" size="40" maxlength="255" id="txtTitre" /> <br /> <label class="boxLabel" accesskey="A" for="lstAlign"><u>A</u>lignement</label> <select class="boxList" name="lstAlign" id="lstAlign"> <option value="">(aucun)</option> <option value="left">Gauche</option> <option value="center">Centre</option> <option value="right">Droite</option> </select> <br /> </fieldset> <div class="boxGroup2"> <button class="boxButton" id="btnValider" onclick="SubmitForm();"> <b>OK </b> </button> <br /> <button class="boxButton" id="btnAnnuler" onclick="window.close();">Annuler</button> </div> </form> </body> </html> <script language="JavaScript" type="text/javascript"> <!-- function InitForm () { // - valeur de retour par défaut pour signifier que rien n'a changé window.returnValue = "~"; // - initialise la zone url document.getElementById("txtUrl").value = window.dialogArguments[0]; // - initialise la zone légende document.getElementById("txtTitre").value = window.dialogArguments[1]; // - initialise la zone alignement document.getElementById("lstAlign").selectedIndex = 0; if (window.dialogArguments[2] == "left") document.getElementById("lstAlign").selectedIndex = 1; if (window.dialogArguments[2] == "center") document.getElementById("lstAlign").selectedIndex = 2; if (window.dialogArguments[2] == "right") document.getElementById("lstAlign").selectedIndex = 3; // met le focus sur la zone de saisie de l'url document.getElementById("txtUrl").focus(); } function CheckKey () { // alert(event.keyCode); // <Entrée> => simule un clic sur [ OK ] if (event.keyCode == 13) document.getElementById("btnValider").click(); // <Echap> => simule un clic sur [ Annuler ] if (event.keyCode == 27) document.getElementById("btnAnnuler").click(); } function SubmitForm () { // Sélection du bouton [ OK ] // - défini le code xhtml de la balise <img ...> var sXhtml; sXhtml = ""; if (document.getElementById("txtUrl").value != "") { // - url de l'image sXhtml = '<img src="' + document.getElementById("txtUrl").value + '"'; // - légende de l'image if (document.getElementById("txtTitre").value != "") sXhtml = sXhtml + ' alt="' + document.getElementById("txtTitre").value + '"'; // - alignement de l'image if (document.getElementById("lstAlign").value != "") sXhtml = sXhtml + ' align="' + document.getElementById("lstAlign").value + '"'; // - bordure de l'image sXhtml = sXhtml + ' border="0px" />'; } // - renvoie le code généré window.returnValue = sXhtml; // - ferme la boite de dialogue window.close(); } //--> </script>