-
help con javascript
Salve, ho realizzato uno script che ricrea un editor visuale, con javascript.
Lo script è associato ad un iFrame reso modificabile dall'utente come se fosse una textarea. Fino a qui nn ho avuto problemi, ora però dovrei richiamare i dati generati e racchiusi nell'iFrame, sempre con un javascript, e inviarli a php che poi li inserirà in un database.
Il fatto è che io nn conosco i javascript, per creare l'editor mi sono affidato ad una guida, quindi se qualcuno fosse cosi gentile da crearmi un piccolo codice che richiami i dati dall'iframe, li racchiuda in una variabile, cosi che mi permetta con php di inserirli in un db.
Oppure se sapete indicarmi un sito con un tutorial o qualcosa di già pronto da consultare, per risolvere il mio problema
Grazie in anticipo a tutti coloro che mi aiuteranno
Ciao
-
Se fai vedere il codice che utilizzi, è possibile provare ad aiutarti.
-
Ok vi posto del codice.
Questo è per rendere editabile l'iframe
Codice HTML:
<script language="JavaScript">
var bHtmlMode = false;
var str_iFrameDoc = (document.all)? "document.frames(\"Composition\").document\;": "document.getElementById(\"Composition\").contentDocument\;";
// Inizializzazione
onload = initialize;
function initialize() {
iFrameDoc = eval(str_iFrameDoc);
iFrameDoc.open();
iFrameDoc.write("<?=$Valore?>"); (2)
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.visibility = "hidden";
}
}
// Porta il focus al riquadro di testo
function setFocus() {
if (document.all)
document.frames("Composition").focus();
else
document.getElementById('Composition').contentWindow.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:", "");
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>
Ora vi posto quello dell'iFrame
Codice HTML:
<IFRAME name="Composition" class="Composition" style="background-color: #FFFFFF; color:#000000; border: none;" width="99%" ID="Composition" height="190"></IFRAME>
EDIT:
nessuno che sa aiutarmi?
Se qualcuno sa aiutarti, stai sicuro che lo farà...