<html> <head> <title>Lien</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 le lien</legend> <label class="boxLabel" accesskey="T" for="lstType"><u>T</u>ype</label> <select class="boxList" name="lstType" onchange="SelectType(this.selectedIndex);" id="lstType"> <option value="">(autre)</option> <option value="ftp://">ftp:</option> <option value="http://">http:</option> <option value="https://">https:</option> <option value="mailto:">mailto:</option> </select> <br /> <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 /> </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é // (sera renvoyé quand clic sur [Annuler] ou [X]) 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 type document.getElementById("lstType").selectedIndex = 0; if (window.dialogArguments[0] == "") SelectType(2); // met le focus sur la zone de saisie de l'url document.getElementById("txtUrl").focus(); } function SelectType (iOption) { // Modification du type de lien document.getElementById("lstType").selectedIndex = iOption; document.getElementById("txtUrl").value = document.getElementById("lstType").value; document.getElementById("txtUrl").focus(); } function CheckKey () { // Appui sur <Entrée> => simule un clic sur [ OK ] if (event.keyCode == 13) document.getElementById("btnValider").click(); // Appui sur <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 <a ...> var sXhtml; sXhtml = ""; if (document.getElementById("txtUrl").value != "") { // - url du lien sXhtml = '<a href="' + document.getElementById("txtUrl").value + '"'; // - légende du lien if (document.getElementById("txtTitre").value != "") sXhtml = sXhtml + ' title="' + document.getElementById("txtTitre").value + '"'; sXhtml = sXhtml + '>'; } // - renvoie le code généré window.returnValue = sXhtml; // - ferme la boite de dialogue window.close(); } //--> </script>