Jamany: CSS in iframe einbinden

Beitrag lesen

Die CSS-Datei muß in der Datei referenziert sein, für welche die
CSS-Definitionen gelten sollen. Ob die Datei in einem Iframe an-
gezeigt wird oder nicht, ist dabei unerheblich.

Doch, die CSS-Definitionen müssen dann in der Datei pdedit.php
stehen bzw. in dieser Datei muß die CSS-Datei referenziert sein.

Aber genau das ist mein Problem.

Ehrlich gesagt kann ich Dein Problem im Moment nicht so ganz nach-
vollziehen, unter der angegebenen Adresse sieht für mich soweit
alles ganz normal aus, d.h. da fehlt offenbar kein CSS.
Und extra die ZIP-Datei herunterladen und da reinschauen, ist mir
zuviel Aufwand, vielleicht schilderst Du einfach nochmal das Pro-
blem genauer.

Ich versuche es einfach nochmal etwas genauer:

Also folgende PHP-Seite (pdedit.php) wird eingebunden - zur Vereinfachung hier der Quelltext: (Die CSS-Datei wird hier eingebunden)

<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<LINK REL="StyleSheet" HREF="themes/XP-Silver/style/style.css" TYPE="text/css">
</head>
<STYLE>
  BODY {margin: 0pt; padding: 0pt; border: none}
  IFRAME {width: 100%; height: 100%; border: none}
</STYLE>
<SCRIPT>
// Default format is WYSIWYG HTML
var format="HTML"

// Set the focus to the editor
function setFocus() {
 textEdit.focus()
}

// Execute a command against the editor
// At minimum one argument is required. Some commands
// require a second optional argument:
// eg., ("formatblock","<H1>") to make an H1

function execCommand(command) {
textEdit.focus()
 if (format=="HTML") {
  var edit = textEdit.document.selection.createRange()
  if (arguments[1]==null)
   edit.execCommand(command)
  else
   edit.execCommand(command,false, arguments[1])
  edit.select()
  textEdit.focus()
 }
}

// Selects all the text in the editor
function selectAllText(){

var edit = textEdit.document;

edit.execCommand('SelectAll');
textEdit.focus();

}

function newDocument() {
        textEdit.document.open()
        textEdit.document.write("")
        textEdit.document.close()
        textEdit.focus()
}

//function loadDoc(htmlString) {
//        textEdit.document.open()
//
//        htmlString=window.opener.document.main.edit.value;
//
//htmlString='Resting';
//        textEdit.document.write(htmlString)
//        textEdit.document.close()
//}
// Initialize the editor with an empty document
function initEditor() {
        var htmlString = parent.document.all.story.value;
        textEdit.document.designMode="On"
        textEdit.document.open()
        textEdit.document.write(htmlString)
        textEdit.document.close()
        textEdit.focus()
}

// Swap between WYSIWYG mode and raw HTML mode
function swapModes() {
        if (format=="HTML") {
                textEdit.document.body.innerText = textEdit.document.body.innerHTML
                textEdit.document.body.style.fontFamily = "monospace"
                textEdit.document.body.style.fontSize = "10pt"
                format="Text"
         }
        else {
                   textEdit.document.body.innerHTML = textEdit.document.body.innerText
                   textEdit.document.body.style.fontFamily = ""
                   textEdit.document.body.style.fontSize =""
                   format="HTML"
         }
        // textEdit.focus()
        var s = textEdit.document.body.createTextRange()
        s.collapse(false)
        s.select()
}

window.onload = initEditor

</SCRIPT>
<!-- Turn off the outer body scrollbars. The IFRAME editbox will display its
     own scrollbars when necessary -->
<BODY SCROLL=No>

<IFRAME ID=textEdit>
</IFRAME>
<script>
textEdit.focus();
</script>
</body>
</html>

-------

Über http://www.entwicklungshilfe.de/submit.php wird dann folgendes aufgerufen:

(Innerhalb eines Formulars):

<textarea name="hometext" style="display: none;"></textarea><iframe id="myEditor" src="./pdedit.php?textareaname=hometext" onFocus="initToolBar(this,'myEditor')" width=100% height=100%></iframe>

Auf der Seite selbst geht das CSS. Mein Problem ist, dass man in dem Editor - der ja ein WYSIWYG-Editor sein sollte - nicht exakt das sieht, was man dann später auf der Seite sieht.
z.B. ist ja auf der Seite die Schriftgröße festgelegt. In dem Editor nicht - da kann man die Schriftgröße beliebig ändern. Und das ist nur ein Beispiel. Damit in dem Editor-Feld exakt das gleiche angezeigt werden kann, wie es auch später online aussieht, müsste bereits in diesem Feld die verwendete CSS-Datei gelten und eingebunden sein. Aber genau das geht nicht...

Jamany