//inhalt des iframes auf das textfeld 'inhalt_editor' kopieren, damit man dieses durch ein formular versenden kann
function inhalt_kopieren() {
if(document.all) {
//IE
html_code = editor.document.body.innerHTML;
document.getElementById('inhalt_editor').value = html_code;
}
else {
//ff
html_code = frames['editor'].document.getElementsByTagName('body')[0].innerHTML;
document.getElementById('inhalt_editor').value = html_code;
}
}
function init() {
if (document.all) { //IE
frames.editor.document.designMode = "On";
}
else { //Mozilla
document.getElementById("editor").contentDocument.designMode = "on";
}
}
//Befehl im Editor (iFrame) ausfürhen
function runCommand(theCommand) {
var theEditor;
if (document.all) { //IE
frames.editor.document.designMode = "On";
frames["editor"].document.execCommand(theCommand, false, ';')
}
else { //Mozilla
document.getElementById("editor").contentDocument.designMode = "on";
document.getElementById("editor").contentWindow.document.execCommand(theCommand, false, ';')
}
}
//Ansichtsmodus 1 = Normal (rich text) ; 2 = html code
var viewMode = 1;
// Other code exists here
function view_source() {
if(document.all) {
//ie
viewsource_ie();
} else {
viewsource_firefox();
}
}
//Quelltext des iframes im IE umwandeln
function viewsource_ie() {
if(viewMode == 1) {
iHTML = editor.document.body.innerHTML;
editor.document.body.innerText = iHTML;
editor.focus();
viewMode = 2;
} else {
iText = editor.document.body.innerText;
editor.document.body.innerHTML = iText;
editor.focus();
viewMode = 1; // WYSIWYG
}
}
//Quelltext des iframes im Firefox umwandeln
function viewsource_firefox() {
var html;
if (viewMode == 1) {
html = document.createTextNode(document.getElementById('editor').contentWindow.document.body.innerHTML);
document.getElementById('editor').contentWindow.document.body.innerHTML = "";
html = document.getElementById('editor').contentWindow.document.importNode(html,false);
document.getElementById('editor').contentWindow.document.body.appendChild(html);
viewMode=2;
} else {
html = document.getElementById('editor').contentWindow.document.body.ownerDocument.createRange();
html.selectNodeContents(document.getElementById('editor').contentWindow.document.body);
document.getElementById('editor').contentWindow.document.body.innerHTML = html.toString();
viewMode=1;
}
}