Bonjour,
S'ils vous plait , j'ai un problème avec mon code , en faite j'essaie de changer la couleur de mon texte , mais ca ne marcha pas
voici mon code:
//code php
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<link rel="stylesheet" href='styleT.css' type="text/css"/>
<script src="editeur.js"></script>
<title>Mon éditeur </title>
</head>
<body>
<input type="button" value="G" style="font-weight:bold;" onclick="document.execCommand('bold', false,name);" ></code>
<input type="button" value="I" style="font-style:italic;" onclick="document.execCommand('italic',false,name);"/></code>
<input type="button" value="S" style="text-decoration:underline;" onclick="document.execCommand('underline',false,name);" /></code>
<input type="button" value="BC" style="text-decoration:backcolor;" onclick="document.execCommand('backcolor',false,'pink');" /></code>
<input type="button" value="B" style="text-decoration:strikethrough;" onclick="document.execCommand('strikethrough',false,name);"/></code>
<select id="couleur" onchange="formatText("couleur")">
<option value="red" style="color:red">Rouge</option>
<option value="green" style="color:green">Vert</option>
<option value="blue" style="color:blue">Bleu</option>
<option value="yellow" style="color:yellow">Jaune</option>
<option value="orangered" style="color:orange">Orange</option>
<option value="grey" style="color:grey">Gris</option>
<option value="silver" style="color:silver">Argent</option>
<option value="pink" style="color:pink">Rose</option>
<option value="beige" style="color:beige">Beige</option>
<option value="brown" style="color:brown">Marron</option>
</select>
<input type="button" value="Lien" onclick="document.execCommand('createLink');" ></code>
<input type="button" value="Image" onclick="commande('insertImage');" ></code>
<input type="button" value="Centrer" style="font-style:justifycenter;" onclick="document.execCommand('justifycenter',false,name);"/></code>
<input type="button" value="Gauche" style="font-style:justifyleft;" onclick="document.execCommand('justifyleft',false,name);"/></code>
<input type="button" value="Droite" style="font-style:justifyright;" onclick="document.execCommand('justifyright',false,name);"/></code>
<div id="editeur" contentEditable ></div>
</body>
</html>
//code javascript:
function commande(nom, argument){
if (typeof argument === 'undefined') {
argument = '';
}
document.execCommand('bold', false,name);
document.execCommand('italic', false,name);
document.execCommand('underline', false,name);
document.execCommand('strikethrough', false,name);
document.execCommand('backColor', false,'pink');
document.execCommand('justifycenter', false,name);
document.execCommand('justifyleft', false,name);
document.execCommand('justifyright', false,name);
switch(nom){
case "createLink":
argument =prompt("Quelle est l'adresse du lien ?");
document.execCommand('createLink');
break;
case "insertImage":
argument = prompt("Quelle est l'adresse de l'image ?");
document.execCommand('insertImage');
break;
case "couleur":
var couleur =document.getElementById("couleur").options[document.getElementById("couleur").selectedIndex].value;
cible.execCommand('ForeColor',false,couleur);
break;
}
}
Veuillez m'aider s'ils vous plait:)
Merci d'avance