Dans la page html :
<a href="javascript:void(yml('sub'))" class="menulink">sub</a>
dans le script :
function MM_findObj(n, d) {
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i>d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); return x;
}
function storeCaret (textEl)
{
if (textEl.createTextRange)
textEl.caretPos = document.selection.createRange().duplicate();
}
function insertAtCaret (textEl, text)
{
if (textEl.createTextRange && textEl.caretPos)
{
var caretPos = textEl.caretPos;
caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? text + ' ' : text;
}
}
function insertInCaret (textEl, text, text2)
{
if (textEl.createTextRange && textEl.caretPos)
{
var caretPos = textEl.caretPos;
selectedtext = caretPos.text
caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == '' ? text + '' : text;
caretPos.text = caretPos.text + selectedtext + text2
}
}
function yml(id) //la fonction principale ...
{
MM_findObj('texte').focus();
if (MM_findObj('texte').createTextRange && MM_findObj('texte').caretPos)
{
var caretPos = MM_findObj('texte').caretPos;
if (caretPos.text.length>0)
{
insertInCaret(MM_findObj('texte'),"["+id+"]","[/"+id+"]")
}
else
{
insertAtCaret(MM_findObj('texte'),"["+id+"][/"+id+"]")
MM_findObj('texte').focus()
}
}
}
function countbalise(b,ch)
{
count = 0;
pos = MM_findObj(ch).value.indexOf(b);
while ( pos != -1 )
{
count++;
pos = MM_findObj(ch).value.indexOf(b,pos+1);
}
return count;
}
voila, voila
tout ca bien sur © Yaro
euh ... PS : si tu vois toujours pas et ben demande ou ca bloque ; je sens que yaro se fera un plaisir de t'expliquer
