Salve
ho un EDITOR HTML all'interno della pagina .php, l'EDITOR è scritto tutto in JAVASCRIPT, ed è un IFRAME dove posso scrivere qualsiasi testo. Supponiamo che faccio copia ed incolla da un file .DOC, memorizzo il testo incollato sul database tramite la funzione:
HTMLENTITIES
adesso voglio richiamare il testo dal DB per la modifica, però prima di visualizzarlo nell'IFRAME richiamo la funzione HTML_ENTITY_DECODE
però l'IFRAME mi dà problemi dicendo "COSTANTE STRING SENZA TERMINAZIONE" e non vieni VISUALIZZATO NULLA ... qualcuno può aiutarmi ????????????
// Riga con cui decodifico il valore nel DB
$Valore = html_entity_decode ( $TESTODALDB); $Valore è passato all'iIFRAME tramite (1)
Questo è il codice JAVASCRIPT che gestisce l'EDITOR HTML :
<script language="JavaScript">
var bHtmlMode = false;
var str_iFrameDoc = (document.all)? "document.frames(\"Composition\").document\;": "document.getElementById(\"Composition\").contentD ocument\;";
// Inizializzazione
onload = initialize;
function initialize() {
iFrameDoc = eval(str_iFrameDoc);
iFrameDoc.open();
iFrameDoc.write("<?=$Valore?>"); ( 1 ) Passaggio nell'IFRAME
iFrameDoc.close();
iFrameDoc.designMode = "On";
document.getElementById("switchMode").checked = false;
if (!document.all) {
document.getElementById("taglia").style.visibility = "hidden";
document.getElementById("copia").style.visibility = "hidden";
document.getElementById("incolla").style.visibilit y = "hidden";
}
}
// Porta il focus al riquadro di testo
function setFocus() {
if (document.all)
document.frames("Composition").focus();
else
document.getElementById('Composition').contentWind ow.focus()
return;
}
// Controlla se la toolbar è abilitata nella modalità testo
function validateMode() {
if (! bHtmlMode)
return true;
alert("Deselezionare \"Visualizza HTML\" per utilizzare le barre degli strumenti");
setFocus();
return false;
}
// Formatta il testo
function formatC(what,opt) {
if (!validateMode())
return;
iFrameDoc = eval(str_iFrameDoc);
if (what == "CreateLink")
{
objectDocument = eval(str_iFrameDoc);
var txt = "";
if (objectDocument.getSelection){
txt = objectDocument.getSelection();
}else if (objectDocument.selection){
txt = objectDocument.selection.createRange().text;
}else{
return;
}
if(txt != ""){
var URL = prompt("Indirizzo:", "http://www.intranetoffice.it/centro/admin/uploaddoc/");
objectDocument.execCommand(what,false,URL);
setFocus();
}else{
alert ("Prima seleziona il testo");
}
}
else
iFrameDoc.execCommand(what,false,opt);
setFocus();
}
//Scambia tra la modalità testo e la modalità HTML.
function setMode(newMode) {
var testo;
bHtmlMode = newMode;
iFrameDoc = eval(str_iFrameDoc);
riquadro = iFrameDoc.body;
if (document.all) {
if (bHtmlMode) {
testo = riquadro.innerHTML;
riquadro.innerText = testo;
} else {
testo = riquadro.innerText;
riquadro.innerHTML = testo;
}
} else if(document.getElementById && document.createTextNode) {
if (bHtmlMode) {
testo = document.createTextNode(riquadro.innerHTML);
riquadro.innerHTML = "";
riquadro.appendChild(testo);
} else {
testo = document.createRange();
testo.selectNodeContents(riquadro);
riquadro.innerHTML = testo.toString();
}
}
setFocus();
}
</script>