Bonjour

J'ai fait un petit script afin de changer les caractères texte en html. Mais petit problème certain caractères ne fonctionnent pas (style "é" par exemple). Je débute en javascript merci de votre compréhension :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
<HTML>
<HEAD> 
<SCRIPT LANGUAGE="javascript">
function afficher(form2) { 
var texte =document.form2.input.value;
texte = texte.replace(/&/g,'&amp;');
texte = texte.replace(/</g,'&lt;');
texte = texte.replace(/>/g,'&gt;');
texte = texte.replace(/'/g,'&rsquo;');
texte = texte.replace(/“/g,'&ldquo;');
texte = texte.replace(/”/g,'&rdquo;');
texte = texte.replace(/«/g,'&laquo;');
texte = texte.replace(/ü/g,'&uuml;');
texte = texte.replace(/û/g,'&ucirc;');
texte = texte.replace(/ú/g,'&uacute;');
texte = texte.replace(/ù/g,'&ugrave;');
texte = texte.replace(/ô/g,'&ocirc;');
texte = texte.replace(/ó/g,'&oacute;');
texte = texte.replace(/ò/g,'&ograve;');
texte = texte.replace(/ï/g,'&iuml;');
texte = texte.replace(/í/g,'&iacute;');
texte = texte.replace(/ë/g,'&euml;');
texte = texte.replace(/ê/g,'&ecirc;');
texte = texte.replace(/é/g,'&eacute;');
texte = texte.replace(/è/g,'&egrave;');
texte = texte.replace(/ç/g,'&ccedil;');
texte = texte.replace(/å/g,'&aring;');
texte = texte.replace(/ä/g,'&auml;');
texte = texte.replace(/â/g,'&acirc;');
texte = texte.replace(/à/g,'&aacute;');
document.form2.output.value=texte; 
} 
</SCRIPT>
</HEAD>
<BODY> 
<FORM NAME="form2"> 
<INPUT TYPE="text" NAME="input" VALUE=""> Zone de texte d&rsquo;entr&eacute;e <BR> 
<INPUT TYPE="button" NAME="bouton" VALUE="Afficher" onClick="afficher(form2)"><BR>
<INPUT TYPE="text" NAME="output" VALUE=""> Zone de texte de sortie 
</FORM> 
</BODY> 
</HTML>