Bonjour à tous, je souhaite personnalisé une alerte.
Alors j'ai le code suivant : Je clique sur un bouton, la boite de dialogue s'affiche, je saisis mon texte, et celui ci s'ajoute dans le textarea sans probleme.
Voici la fonction qui affiche l'arlert.
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
|
// Insert URL Tag
function ins_url(theform) {
// inserts named url link - <a href="http://mylink new=true" target="_blank">text</a>
link_url = prompt('Entrez lÂURL complète du lien'+'\n',"http://");
if ( (link_url != null) ) {
// Get selected text
var link_text = getSelectedText(theform);
if (link_text == '') {
// Display prompt if no text is selected
link_text = prompt('Entrez le texte associé au lien (optionnel)'+'\n<a href="http://xxx" target="_blank">xxx</a>',"");
}
if ( (link_text == null) || (link_text == '') ) {
link_text = link_url;
}
link_target = prompt('Ouvrir l´URL dans une nouvelle fenêtre (optionnel):'+'\n','');
str = '<a href="http://+link_url;
if ((link_target != null) && (link_target != '')) {
link_target.toLowerCase;
if ( link_target == 'true' || link_target == 'false' ) {
str += ' new='+link_target;
}
}
str +=" target="_blank">'+link_text+'</a>';
insertAtCaret(theform, str);
theform.focus();
}
} |
D'un autre coté, j'ai trouvé ce code : http://javascript.internet.com/text-...pt-prompt.html
avec la fonction
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
| var response = null
function prompt2(promptpicture, prompttitle, message, sendto) {
promptbox = document.createElement('div');
promptbox.setAttribute ('id' , 'prompt')
document.getElementsByTagName('body')[0].appendChild(promptbox)
promptbox = eval("document.getElementById('prompt').style")
promptbox.position = 'absolute'
promptbox.top = 100
promptbox.left = 200
promptbox.width = 300
promptbox.border = 'outset 1 #bbbbbb'
document.getElementById('prompt').innerHTML = "<table cellspacing='0' cellpadding='0' border='0' width='100%'><tr valign='middle'><td width='22' height='22' style='text-indent:2;' class='titlebar'><img src='" + promptpicture + "' height='18' width='18'></td><td class='titlebar'>" + prompttitle + "</td></tr></table>"
document.getElementById('prompt').innerHTML = document.getElementById('prompt').innerHTML + "<table cellspacing='0' cellpadding='0' border='0' width='100%' class='promptbox'><tr><td>" + message + "</td></tr><tr><td><input type='text' id='promptbox' onblur='this.focus()' class='promptbox'></td></tr><tr><td align='right'><br><input type='button' class='prompt' value='OK' onMouseOver='this.style.border=\"1 outset #dddddd\"' onMouseOut='this.style.border=\"1 solid transparent\"' onClick='" + sendto + "(document.getElementById(\"promptbox\").value); document.getElementsByTagName(\"body\")[0].removeChild(document.getElementById(\"prompt\"))'> <input type='button' class='prompt' value='Cancel' onMouseOver='this.style.border=\"1 outset transparent\"' onMouseOut='this.style.border=\"1 solid transparent\"' onClick='" + sendto + "(\"\"); document.getElementsByTagName(\"body\")[0].removeChild(document.getElementById(\"prompt\"))'></td></tr></table>"
document.getElementById("promptbox").focus()
} |
J'aimerai adapter ma premiere fonction pour qu'elle arrive à etre personnalisé comme la deuxieme.
Si je fais ca :
link_url = prompt("<table cellspacing='0' cellpadding='0' border='0' width='100%'><tr valign='middle'><td width='22' height='22' style='text-indent:2;' class='titlebar'><img src='' height='18' width='18'></td><td class='titlebar'></td></tr></table>" );
Cela m'affiche le code en brut.
Pouvez-vous m'aider à trouver la syntaxe pour personnalisé ma premiere fonction
Merci d'avance!!
Partager