Forum de discussion
Forum « Programmation Javascript » (archives)
Re: Urgent !!! Script pour le traitement du texte
Envoyé: 14 mars 2003, 8h38 par Oznog
Avec un textarea (attention pas texterea) ce n'est pas possible. Tu peux comme di quino te faire un bouton qui ajoute les balises <b> et </b>. Un simple bouton B qui fait un
onClick="document.monForm.ChampTextArea.value='<b>votre texte ici</b>."
La solution sur asp-php doit être un peux ça.
SINON, TU AS LE IfRAME ET JE SOUPSONNE QUE C'EST CE DONT TU PARLE. Note que ça fait plusieurs fois que je donne ce code, je ne me souvient plus d'où il vient. Alors une petite recherche sur le forum (et ça compte aussi bien pour quino au lieu d'envoyer tous mes visiteur ailleurs) avec le mot clé "textarea" t'aurais donnée la réponse. Alors voilà le code sans modif... (bien sûr les images ne sonmt pas là mais il fait le "gras" que tu demande.
<html>
<head>
<title>FAQs</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" href="global.css" type="text/css">
<STYLE TYPE="text/css">
txtbtn {font-family:tahoma; font-size:70%; color:menutext;}
FORM SELECT {
font-family: 'Microsoft Sans Serif', Verdana, sans-serif;
background-color: #ffffe8;
font-size: 8pt;
color: #000000;
}
FORM INPUT {
background-color: #efefef;
font-family: 'Microsoft Sans Serif', sans-serif;
font-size: 10pt;
}
</STYLE>
<script LANGUAGE="JavaScript">
<!--
function button_over(eButton) {
eButton.style.backgroundColor = "#B5BDD6";
eButton.style.borderColor = "darkblue darkblue darkblue darkblue";
}
function button_out(eButton) {
eButton.style.backgroundColor = "#efedde";
eButton.style.borderColor = "#efedde";
}
function button_down(eButton) {
eButton.style.backgroundColor = "#8494B5";
eButton.style.borderColor = "darkblue darkblue darkblue darkblue";
}
function button_up(eButton) {
eButton.style.backgroundColor = "#B5BDD6";
eButton.style.borderColor = "darkblue darkblue darkblue darkblue";
eButton = null;
}
var isHTMLMode=false
function document.onreadystatechange() {
idContent.document.designMode = "On";
}
function cmdExec(cmd,opt) {
if (isHTMLMode) {
alert("Please uncheck 'Edit HTML'");
return;
}
idContent.document.execCommand(cmd,"",opt);
idContent.focus();
}
function setMode(bMode) {
var sTmp;
isHTMLMode = bMode;
if (isHTMLMode) {
sTmp=idContent.document.body.innerHTML;
idContent.document.body.innerText=sTmp;
} else {
sTmp=idContent.document.body.innerText;
idContent.document.body.innerHTML=sTmp;
}
idContent.focus();
}
function createLink() {
if (isHTMLMode) {
alert("Please uncheck 'Edit HTML'");
return;
}
cmdExec("CreateLink");
}
function insertImageLink() {
if (isHTMLMode) {
alert("Please uncheck 'Edit HTML'");
return;
}
var sImgSrc=prompt("Insert Image File (You can use your local image file)");
if(sImgSrc!=null) cmdExec("InsertImage",sImgSrc);
}
function insertImageLocal() {
if (isHTMLMode) {
alert("Please uncheck 'Edit HTML'");
return;
}
var sImgSrc = showModalDialog("selectImage.asp","","dialogHeight: 500px; dialogWidth: 400px; dialogTop: px; dialogLeft: px; edge: Raised; center: Yes; help: No; resizable: Yes; status: No;");
if(sImgSrc!=null) cmdExec("InsertImage",sImgSrc);
}
function uploadImages() {
var newWindow;
var props = 'scrollBars=yes,resizable=yes,toolbar=no,menubar=no,location=no,directories=no,width=500,height=500,top=100,left=200';
newWindow = window.open('upload.asp', 'Upload_Images_to_server', props);
}
function SubmitContent() {
if (isHTMLMode) {
alert("Please uncheck 'Edit HTML'");
return (false);
}
document.editor.YOUR_CONTENT.value = idContent.document.body.innerHTML;
document.editor.submit();
}
function foreColor() {
var arr = showModalDialog("selcolor.asp","","font-family:Verdana; font-size:12; dialogWidth:45em; dialogHeight:24em" );
if (arr != null) cmdExec("ForeColor",arr);
}
-->
</script>
</head>
<body bgcolor="#ffffff" onload="idContent.focus();">
<p class="body"><font size="+1">Web-based Content Editor using IFrame</font>
<!--Editor starts here -->
<form name="editor" method="post" action="html.asp">
<table border="0" cellpadding="1" cellspacing="0">
<tr>
<td bgcolor="#d2b48c">
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<td align="top" bgcolor="#efedde">
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<td>
<select onchange="cmdExec('formatBlock',this[this.selectedIndex].value);this.selectedIndex=0">
<option selected>Style</option>
<option value="Normal">Normal</option>
<option value="Heading 1">Heading 1</option>
<option value="Heading 2">Heading 2</option>
<option value="Heading 3">Heading 3</option>
<option value="Heading 4">Heading 4</option>
<option value="Heading 5">Heading 5</option>
<option value="Address">Address</option>
<option value="Formatted">Formatted</option>
<option value="Definition Term">Definition Term</option>
</select>
<select onchange="cmdExec('fontname',this[this.selectedIndex].value);">
<option selected>Font</option>
<option value="Arial">Arial</option>
<option value="Arial Black">Arial Black</option>
<option value="Arial Narrow">Arial Narrow</option>
<option value="Comic Sans MS">Comic Sans MS</option>
<option value="Courier New">Courier New</option>
<option value="System">System</option>
<option value="Tahoma">Tahoma</option>
<option value="Times New Roman">Times New Roman</option>
<option value="Verdana">Verdana</option>
<option value="Wingdings">Wingdings</option>
</select>
<select onchange="cmdExec('fontsize',this[this.selectedIndex].value);">
<option selected>Size</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="10">10</option>
<option value="12">12</option>
<option value="14">14</option>
</select>
</td>
<td nowrap height="22"> <img hspace="1" vspace="1" align=absmiddle src="images/imageUpload.gif" alt="Upload Images" onClick="uploadImages()" onmouseover="button_over(this);" onmouseout="button_out(this);" onmousedown="button_down(this);" onmouseup="button_up(this);">
<img hspace="1" vspace=1 align=absmiddle src="images/imageLocal.gif" alt="Insert Local Image" onClick="insertImageLocal()" onmouseover="button_over(this);" onmouseout="button_out(this);" onmousedown="button_down(this);" onmouseup="button_up(this);">
<img hspace="1" vspace=1 align=absmiddle src="images/imageLink.gif" alt="Insert Link to External Image" onClick="insertImageLink()" onmouseover="button_over(this);" onmouseout="button_out(this);" onmousedown="button_down(this);" onmouseup="button_up(this);">
<img hspace="1" vspace=1 align=absmiddle src="images/Link.gif" alt="Insert Link" onClick="cmdExec('createLink')" onmouseover="button_over(this);" onmouseout="button_out(this);" onmousedown="button_down(this);" onmouseup="button_up(this);">
</td>
</tr>
</table>
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<td nowrap height="22"> <img hspace="1" vspace=1 align=absmiddle src="images/Cut.gif" alt="Cut" onClick="cmdExec('cut')" onmouseover="button_over(this);" onmouseout="button_out(this);" onmousedown="button_down(this);" onmouseup="button_up(this);">
<img hspace="1" vspace=1 align=absmiddle src="images/Copy.gif" alt="Copy" onClick="cmdExec('copy')" onmouseover="button_over(this);" onmouseout="button_out(this);" onmousedown="button_down(this);" onmouseup="button_up(this);">
<img hspace="1" vspace=1 align=absmiddle src="images/Paste.gif" alt="Paste" onClick="cmdExec('paste')" onmouseover="button_over(this);" onmouseout="button_out(this);" onmousedown="button_down(this);" onmouseup="button_up(this);">
<img hspace="1" vspace=1 align=absmiddle src="images/Undo.gif" alt="Undo" onClick="cmdExec('Undo')" onmouseover="button_over(this);" onmouseout="button_out(this);" onmousedown="button_down(this);" onmouseup="button_up(this);">
<img hspace="1" vspace=1 align=absmiddle src="images/Bold.gif" alt="Bold" onClick="cmdExec('bold')" onmouseover="button_over(this);" onmouseout="button_out(this);" onmousedown="button_down(this);" onmouseup="button_up(this);">
<img hspace="1" vspace=1 align=absmiddle src="images/Italic.gif" alt="Italics" onClick="cmdExec('italic')" onmouseover="button_over(this);" onmouseout="button_out(this);" onmousedown="button_down(this);" onmouseup="button_up(this);">
<img hspace="1" vspace=1 align=absmiddle src="images/under.gif" alt="Underline" onClick="cmdExec('underline')" onmouseover="button_over(this);" onmouseout="button_out(this);" onmousedown="button_down(this);" onmouseup="button_up(this);">
<img hspace="1" vspace=1 align=absmiddle src="images/Strikethrough.gif" alt="Strike-through" onClick="cmdExec('StrikeThrough')" onmouseover="button_over(this);" onmouseout="button_out(this);" onmousedown="button_down(this);" onmouseup="button_up(this);">
<img hspace="1" vspace=1 align=absmiddle src="images/Superscript.gif" alt="Superscript" onClick="cmdExec('SuperScript')" onmouseover="button_over(this);" onmouseout="button_out(this);" onmousedown="button_down(this);" onmouseup="button_up(this);">
<img hspace="1" vspace=1 align=absmiddle src="images/Subscript.gif" alt="Subscript" onClick="cmdExec('SubScript')" onmouseover="button_over(this);" onmouseout="button_out(this);" onmousedown="button_down(this);" onmouseup="button_up(this);">
<img hspace="1" vspace=1 align=absmiddle src="images/left.gif" alt="Justify Left" onClick="cmdExec('justifyleft')" onmouseover="button_over(this);" onmouseout="button_out(this);" onmousedown="button_down(this);" onmouseup="button_up(this);">
<img hspace="1" vspace=1 align=absmiddle src="images/Center.gif" alt="Center" onClick="cmdExec('justifycenter')" onmouseover="button_over(this);" onmouseout="button_out(this);" onmousedown="button_down(this);" onmouseup="button_up(this);">
<img hspace="1" vspace=1 align=absmiddle src="images/right.gif" alt="Justify Right" onClick="cmdExec('justifyright')" onmouseover="button_over(this);" onmouseout="button_out(this);" onmousedown="button_down(this);" onmouseup="button_up(this);">
<img hspace="1" vspace=1 align=absmiddle src="images/numlist.gif" alt="Ordered List" onClick="cmdExec('insertorderedlist')" onmouseover="button_over(this);" onmouseout="button_out(this);" onmousedown="button_down(this);" onmouseup="button_up(this);">
<img hspace="1" vspace=1 align=absmiddle src="images/inindent.gif" alt="Increase Indent" onClick="cmdExec('indent')" onmouseover="button_over(this);" onmouseout="button_out(this);" onmousedown="button_down(this);" onmouseup="button_up(this);">
<img hspace="1" vspace=1 align=absmiddle src="images/outdent.gif" alt="Decrease Indent" onClick="cmdExec('outdent')" onmouseover="button_over(this);" onmouseout="button_out(this);" onmousedown="button_down(this);" onmouseup="button_up(this);">
<img hspace="1" vspace=1 align=absmiddle src="images/HR.gif" alt="Insert Horizontal Rule" onClick="cmdExec('InsertHorizontalRule')" onmouseover="button_over(this);" onmouseout="button_out(this);" onmousedown="button_down(this);" onmouseup="button_up(this);">
<img hspace="1" vspace=1 align=absmiddle src="images/fgcolor.gif" alt="Forecolor" onClick="foreColor()" onmouseover="button_over(this);" onmouseout="button_out(this);" onmousedown="button_down(this);" onmouseup="button_up(this);">
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td><iframe width="600" id="idContent" height="280"></iframe></td>
</tr>
<tr>
<td bgcolor="#efedde" align="right">
<table border="0" cellpadding="0" cellspacing="0" align="left">
<tr>
<td class="body"><input type="checkbox" onclick="setMode(this.checked)">Edit HTML
<input name="YOUR_CONTENT" type="hidden" value=""></td>
</tr>
</table>
<input type="button" name="Submit" value="Save and Submit »" onclick="SubmitContent();">
</td>
</tr>
</table>
</td>
</tr>
</table>
</form>
<!-- editor ends here -->
<p> </p>
</body>
</html>
Ciao
Oznog
Réponses
|