Insertion d'info dans un textarea
Bonjour a tous,
voila j'essaie de faire un petit menu au dessus d'un textarea pour la mise en forme de mon texte (bouton qui insert <b></b> par exemple).
J'utilise un fichier barreoutil.js dans lequel j'ai mis mes fonctions :
Code:
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 34 35 36 37 38 39 40
|
function format(f, champ) {
var str = document.selection.createRange().text;
that = document.entryform [champ];
that.focus();
var sel = document.selection.createRange();
sel.text = "<" + f + ">" + str + "</" + f + ">";
return;
}
function lien(champ) {
var str = document.selection.createRange().text;
that = document.entryform [champ];
that.focus();
var lien = prompt("URL:","http://");
if (lien != null) {
var sel = document.selection.createRange();
sel.text = "<a href=\"" + lien + "\">" + str + "</a>";
}
return;
} |
J'utilise aussi dans mon fichier CSS la fonction outil avec le .out et .over :
Code:
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
|
#outils {
width: 100%;
background: buttonface;
border-top: 1px solid buttonhighlight;
border-left: 1px solid buttonhighlight;
border-bottom: 1px solid buttonshadow;
border-right: 1px solid buttonshadow;
margin: 0;
text-align:left;
}
.out {
background: buttonface;
border: 1px solid buttonface;
margin: 1;
}
.over {
background: buttonface;
border-top: 1px solid buttonhighlight;
border-left: 1px solid buttonhighlight;
border-bottom: 1px solid buttonshadow;
border-right: 1px solid buttonshadow;
margin: 1;
} |
et je met dans mon form le code correspondans a l'action que je lui demande :
Code:
1 2 3 4 5 6 7
|
<div id="outils">
<img class="out" src="images/bold.gif" width="16" height="16" align="middle" onMouseOver="this.className='over';" onMouseOut="this.className='out';" onClick="format('b', 'adresse');">
<img class="out" src="images/italic.gif" width="16" height="16" align="middle" onMouseOver="this.className='over';" onMouseOut="this.className='out';" onClick="format('i', 'adresse');">
<img class="out" src="images/ahref.gif" width="16" height="16" align="middle" onMouseOver="this.className='over';" onMouseOut="this.className='out';" onClick="lien('adresse');">
</div>
<textarea name="adresse" rows="10" cols="50"></textarea> |
quand je charge ma page internet je vois bien mes icones quand je les survoles je les vois bien bouger par contre mon evenement onClick ne fait une erreure cela me marque : Objet attendu
La je vous avous je ne vois pas de quoi cela vient quelq'un aurait il une idée ?
Merci d'avance
Krown