Przerabiam (lub dostosowuję do swoich potrzeb) darmowy edytor WYSIWYG - http://freerichtexteditor.com/about
Strona po edycja zwracana jest przez GET do przeglądarki, a ja chciałbym uzyskać kod strony w POST-ie (jeśli dobrze pamiętam to jest ograniczenie na długość w GET no i ze względów estetycznych wolałbym to w POST-ie.
Kod php uruchamiający skrypt wygląda następująco (oryginalny przykład do programu)
<?php
function freeRTE_Preload($content) {
// Strip newline characters.
$content = str_replace(chr(10), " ", $content);
$content = str_replace(chr(13), " ", $content);
// Replace single quotes.
$content = str_replace(chr(145), chr(39), $content);
$content = str_replace(chr(146), chr(39), $content);
// Return the result.
return $content;
}
// Send the preloaded content to the function.
$content = freeRTE_Preload("<i>This is some <b><br>preloaded</b> content</i>")
?>
<form method="get">
<!-- Include the Free Rich Text Editor Runtime -->
<script src="../js/richtext.js" type="text/javascript" language="javascript"></script>
<!-- Include the Free Rich Text Editor Variables Page -->
<script src="../js/config.js" type="text/javascript" language="javascript"></script>
<!-- Initialise the editor -->
<script>
initRTE('<?= $content ?>', 'example.css');
</script>
<input type="submit">
</form>
Próbowałem przechwycić '$content' ale wyświetla za każdym razem jedynie 'This is some preloaded content'.
W tym edytorze można podglądać kod html który następnie jest wysyłany przez get-a. Nie wiem jednak jak odnieść się do js z poziomu php. Trzeba napisać jakąś funkcję która zwróci to co chcę czy jest jakiś prostszy sposób? Próbowałem już zmieniać get na post, dodawać value do submit itd. ale dalej albo nic nie otrzymuje albo ten przykładowy tekst...
Kodu dla JS już nie wkleję bo jest za długi. Znalazłem taki kod do które odwołuje się program żeby wyświetlić podgląd kodu html tworzonej strony:
if (id == "rte_code_mode") { rteFormHandler(); document.getElementById(rteFormName).value = getXHTML(trim(document.getElementById(rteName).contentWindow.document.body.innerHTML)); document.getElementById("tb1").style.display = "none"; document.getElementById("tb2").style.display = "none"; document.getElementById("tb3").style.display = "none"; document.getElementById(rteFormName).style.display = ""; document.getElementById(rteName).style.display = "none"; document.getElementById("preview_" + rteName).style.display = "none";}
Czy mógłbym prosić o pomoc jak z tego wyciągnąć ten kod i przesłać POST-em?
wklejam jeszcze kawałek kodu który jest chyba wywoływany przy naciśnięciu submit, kiedy przesyłany jest kod strony
function startRTE(rtePreloadContent) { rteCSS = document.getElementById("preview_css").value; var kids = document.getElementsByTagName("FORM"); for (var i=0; i < kids.length; i++) { kids[i].onsubmit = rteFormHandler;}
document.getElementById(rteName).contentWindow.document.designMode = "on"; document.getElementById(rteFormName).value = rtePreloadContent; document.getElementById(rteName).contentWindow.document.open(); document.getElementById(rteName).contentWindow.document.write("<html><head><style type=\"text/css\">@import url("+rteCSS+");</style></head><body>" + rtePreloadContent + "</body></html>"); document.getElementById(rteName).contentWindow.document.close(); if (document.all && !window.opera) { document.getElementById(rteName).contentWindow.document.attachEvent("onkeypress", rteSelection); document.getElementById(rteName).contentWindow.document.attachEvent("onclick", rteSelection); document.getElementById(rteName).contentWindow.document.attachEvent("onmouseup", rteSelection);} else { document.getElementById(rteName).contentWindow.document.execCommand("useCSS", false, null); document.getElementById(rteName).contentWindow.document.addEventListener("keypress", rteSelection, true); document.getElementById(rteName).contentWindow.document.addEventListener("click", rteSelection, true); document.getElementById(rteName).contentWindow.document.addEventListener("mouseup", rteSelection, true);}
rteSelection(); var kids = document.getElementsByTagName("DIV"); for (var i=0; i < kids.length; i++) { if(kids[i].className == "rtebtn6"){ kids[i].onmouseover = rteBtnMouseOverBottom; kids[i].onmouseout = rteBtnMouseOutBottom; kids[i].onmousedown = rteBtnMouseDownBottom; kids[i].onmouseup = rteBtnMouseUpBottom;}
}
}