J'ai une liste déroulante me permettant d'afficher de la couler dans le texte (comme sur ce forum et d'autre très nombreux).
Seulement, sous IE, rien.....je sélectionne du texte, je choisis la couleur, rien, je clique sans sélectionner du texte, rien......
Voila la façon dont j'ai codé la liste :
Code : Tout sélectionner
<select name="color" id="color" value="color">
<option>Couleur</option>
<option onClick="javascript:bbcode(\'[color=red]\', \'[/color]\');return(false)"/></a>Rouge</option>
<option onClick="javascript:bbcode(\'[color=green]\', \'[/color]\');return(false)"/></a>Vert</option>
<option onClick="javascript:bbcode(\'[color=blue]\', \'[/color]\');return(false)"/></a>Bleu</option>
<option onClick="javascript:bbcode(\'[color=grey]\', \'[/color]\');return(false)"/></a>Gris</option>
</select>Je ne sais pas si c'est nécessaire, mais voila la fonction bbcode associées :
Code : Tout sélectionner
function bbcode(bbdebut, bbfin)
{
var input = window.document.formulaire.mess;
input.focus();
/* pour IE (toujours un cas a par lui ;) )*/
if( typeof document.selection != 'undefined' ) {
var range = document.selection.createRange();
var insText = range.text;
range.text = bbdebut + insText + bbfin;
range = document.selection.createRange();
if (insText.length == 0) {
range.move('character', -bbfin.length);
}
else {
range.moveStart('character', bbdebut.length + insText.length + bbfin.length);
}
range.select();
}
/* pour les navigateurs plus récents que IE comme Firefox... */
else if(typeof input.selectionStart != 'undefined') {
var start = input.selectionStart;
var end = input.selectionEnd;
var insText = input.value.substring(start, end);
input.value = input.value.substr(0, start) + bbdebut + insText + bbfin + input.value.substr(end);
var pos;
if (insText.length == 0) {
pos = start + bbdebut.length;
}
else {
pos = start + bbdebut.length + insText.length + bbfin.length;
}
input.selectionStart = pos;
input.selectionEnd = pos;
}
/* pour les autres navigateurs comme Netscape... */
else {
var pos;
var re = new RegExp('^[0-9]{0,3}$');
while(!re.test(pos)) {
pos = prompt("insertion (0.." + input.value.length + "):", "0");
}
if(pos > input.value.length) {
pos = input.value.length;
}
var insText = prompt("Veuillez taper le texte");
input.value = input.value.substr(0, pos) + bbdebut + insText + bbfin + input.value.substr(pos);
}
}Donc, s'il-vous-plait, parlez douuuuuuucement pour les explications
Merci d'avance à tous