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 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119
| <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>outils</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<script type="text/javascript">
<!--
function insertion(repdeb, repfin, champ1) {
/*Déclaration de la variable input. On lui indique quelle prend pour valeur le contenu
du champ de formulaire textarea qui à pour nom 'saisie'*/
var input = document.forms["form1"].elements[champ1];
input.focus();
if(typeof document.selection != 'undefined') {
var range = document.selection.createRange();
var insText = range.text;
range.text = repdeb + insText + repfin;
range = document.selection.createRange();
if (insText.length == 0) {
range.move('character', -repfin.length);
} else {
range.moveStart('character', repdeb.length + insText.length + repfin.length);
}
range.select();
}
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) + repdeb + insText + repfin + input.value.substr(end);
var pos;
if (insText.length == 0) {
pos = start + repdeb.length;
} else {
pos = start + repdeb.length + insText.length + repfin.length;
}
input.selectionStart = pos;
input.selectionEnd = pos;
}
else
{
var pos;
var re = new RegExp('^[0-9]{0,3}$');
while(!re.test(pos)) {
pos = prompt("Insertion à la position (0.." + input.value.length + "):", "0");
}
if(pos > input.value.length) {
pos = input.value.length;
}
var insText = prompt("Veuillez entrer le texte à formater:");
input.value = input.value.substr(0, pos) + repdeb + insText + repfin + input.value.substr(pos);
}
}
function ecriture(champ1, affiche) {
var des = document.forms["form1"].elements[champ1].value;
var res = document.getElementById(affiche).innerHTML=des;
}
//-->
</script>
</head>
<body>
<input type="button" value="B" id="gras" onclick='insertion("<strong>", "</strong>","texte")' />
<input type="button" value="I" id="ital" onclick="insertion('<em>', '</em>','texte')" />
<input type="button" value="S" id="souli" onclick="insertion('<u>', '</u>', 'texte')" />
<input type="button" value="Retour Ligne" id="retourligne" onclick="insertion('<br />', '', 'texte')" />
<input type="button" value="Voir" id="gras2" onclick="ecriture('texte','regarde')" />
<p><a href="#" onclick="zone1('texte')">zone1</a> <a href="#">zone2 </a></p>
<p>
</p>
<p> </p>
<p>n°1</p>
<form name="form1" id="form1" method="post" action="">
<p>
<textarea name="texte" cols="40" rows="5" id="texte"></textarea>
</p>
<p> </p>
<div id="regarde">Placez ici le contenu de id "regarde"</div>
<p> </p>
<p>n°2</p>
<p>
<textarea name="texte2" cols="40" rows="5" id="texte2"></textarea>
</p>
<p> </p>
<div id="regarde2">Placez ici le contenu de id "regarde2"</div>
<p> </p>
</form>
<a href="#" onclick="zone1()">zone1</a>
<p> </p>
</body>
</html> |
Partager