Hi folgendes, ich möchte gerne in ein Iframe schreiben. Sprich es wird von einem verstecken text_area welches über submit übergeben wurde, soll jetzt der Text wieder in das Iframe geschrieben werden. Mein Problem ist, dass er immer sschreibt er das innerHTML undefiniert oder Null ist. Wieso kann ich nicht auf das Iframe zugreifen?
Hier ein paar Codschnipsel:
<head>
function writeDataImage(breite,hoehe)
{
document.getElementById("text2").value = document.getElementById("text").value;
//alert(breite+' '+hoehe);
}
</head>
<Body>
<div id = "imagebar">
<form action = './index.php?imageUpload=1' method = "POST" name = 'imageForm' onSubmit = 'writeDataImage(document.getElementById("imagebreite").value,document.getElementById("imagehoehe").value);'>
<table border=0 width=900px>
<tr valign = top>
<td width=10px><img src = './images/blank.png' height=25px width=10px border=0></td>
<td width=425px>
<table border=0 height=1px>
<tr valign = top>
<td><span class = "text_schriftart_bezeichnung"><b>Bild:</b></span> </td>
<td><span class = "text_schriftart_bezeichnung"><input type = 'file' name = 'imagupload' id = 'imagupload' value = ''></span> </td>
<td><span class = "text_schriftart_bezeichnung"><b>Breite:</b></span> </td>
<td><span class = "text_schriftart_bezeichnung"><input type = 'text' name = 'imagebreite' id = 'imagebreite' value = '' size=4></span> </td>
<td><span class = "text_schriftart_bezeichnung"><b>Höhe:</b></span> </td>
<td><span class = "text_schriftart_bezeichnung"><input type = 'text' name = 'imagehoehe' id = 'imagehoehe' value = '' size=4></span> </td>
<td><input type = 'submit' name = 'sendImage' value = '+'></td>
<textarea id = 'text2' name = 'test_text2' style = 'height:300px; width:400px; display: none;'></textarea>
</tr>
</table>
</td>
<td align = right><img src="./images/toolbar/pfeiloben_kl.png" style="width:25px; height:25px;" alt="" onMouseDown = "ausblendenToolbar('imagebar');"></td>
</tr>
</table>
</form>
</div>
<form action = './entry.php' method = 'POST' name = 'formular_save' style = 'width:900px;'>
<!--Iframe zum schreiben -->
<iframe src = './editor.php' id = 'frame' class = 'iframe_design'>
</iframe>
<?php
if (isset($_POST["test_text2"]))
{
echo "<textarea id = 'text' name = 'test_text' style = 'height:300px; width:400px; display: block;'>$_POST[test_text2]</textarea>";
}
else
{
?>
<textarea id = 'text' name = 'test_text' style = 'height:300px; width:400px; display: none;'></textarea>
<?php
}
?>
<?php
if (isset($_GET["newMain"]))
{
echo "<input type = 'hidden' id = 'save_viewmaintext' name = 'save_viewmaintext' value = ''>";
echo "<input type = 'hidden' name ='save_mainpoint' value = ''>";
}
else if (isset($_GET["newSite"]))
{
echo "<input type = 'hidden' id = 'save_viewshorttext' name = 'save_viewshorttext' value = ''>";
echo "<input type = 'hidden' name ='save_site' value = ''>";
}
?>
<br>
<table border=0 width = 900px class = 'border_save_button'>
<tr>
<td align = 'center'><img src = './images/system/save_kl.png' height=60px onClick = 'document.formular_save.submit();'> </td>
</tr>
</table>
</form>
x
<script language = "JavaScript">
document.getElementById("frame").contentWindow.addEventListener(
"keyup",
function () {
document.getElementById("frame").contentWindow.focus();
document.getElementById("text").value = document.getElementById("frame").contentWindow.document.body.innerHTML;
},
true);
</script>
<script language = 'JavaScript'>
//alert(document.getElementById('text').value);
document.getElementById("frame").contentWindow.document.body.innerHTML = "xxxxxxx";
</script>
</Body>
Hier ein paar Codschnipsel:
<head>
function writeDataImage(breite,hoehe)
{
document.getElementById("text2").value = document.getElementById("text").value;
//alert(breite+' '+hoehe);
}
</head>
<Body>
<div id = "imagebar">
<form action = './index.php?imageUpload=1' method = "POST" name = 'imageForm' onSubmit = 'writeDataImage(document.getElementById("imagebreite").value,document.getElementById("imagehoehe").value);'>
<table border=0 width=900px>
<tr valign = top>
<td width=10px><img src = './images/blank.png' height=25px width=10px border=0></td>
<td width=425px>
<table border=0 height=1px>
<tr valign = top>
<td><span class = "text_schriftart_bezeichnung"><b>Bild:</b></span> </td>
<td><span class = "text_schriftart_bezeichnung"><input type = 'file' name = 'imagupload' id = 'imagupload' value = ''></span> </td>
<td><span class = "text_schriftart_bezeichnung"><b>Breite:</b></span> </td>
<td><span class = "text_schriftart_bezeichnung"><input type = 'text' name = 'imagebreite' id = 'imagebreite' value = '' size=4></span> </td>
<td><span class = "text_schriftart_bezeichnung"><b>Höhe:</b></span> </td>
<td><span class = "text_schriftart_bezeichnung"><input type = 'text' name = 'imagehoehe' id = 'imagehoehe' value = '' size=4></span> </td>
<td><input type = 'submit' name = 'sendImage' value = '+'></td>
<textarea id = 'text2' name = 'test_text2' style = 'height:300px; width:400px; display: none;'></textarea>
</tr>
</table>
</td>
<td align = right><img src="./images/toolbar/pfeiloben_kl.png" style="width:25px; height:25px;" alt="" onMouseDown = "ausblendenToolbar('imagebar');"></td>
</tr>
</table>
</form>
</div>
<form action = './entry.php' method = 'POST' name = 'formular_save' style = 'width:900px;'>
<!--Iframe zum schreiben -->
<iframe src = './editor.php' id = 'frame' class = 'iframe_design'>
</iframe>
<?php
if (isset($_POST["test_text2"]))
{
echo "<textarea id = 'text' name = 'test_text' style = 'height:300px; width:400px; display: block;'>$_POST[test_text2]</textarea>";
}
else
{
?>
<textarea id = 'text' name = 'test_text' style = 'height:300px; width:400px; display: none;'></textarea>
<?php
}
?>
<?php
if (isset($_GET["newMain"]))
{
echo "<input type = 'hidden' id = 'save_viewmaintext' name = 'save_viewmaintext' value = ''>";
echo "<input type = 'hidden' name ='save_mainpoint' value = ''>";
}
else if (isset($_GET["newSite"]))
{
echo "<input type = 'hidden' id = 'save_viewshorttext' name = 'save_viewshorttext' value = ''>";
echo "<input type = 'hidden' name ='save_site' value = ''>";
}
?>
<br>
<table border=0 width = 900px class = 'border_save_button'>
<tr>
<td align = 'center'><img src = './images/system/save_kl.png' height=60px onClick = 'document.formular_save.submit();'> </td>
</tr>
</table>
</form>
x
<script language = "JavaScript">
document.getElementById("frame").contentWindow.addEventListener(
"keyup",
function () {
document.getElementById("frame").contentWindow.focus();
document.getElementById("text").value = document.getElementById("frame").contentWindow.document.body.innerHTML;
},
true);
</script>
<script language = 'JavaScript'>
//alert(document.getElementById('text').value);
document.getElementById("frame").contentWindow.document.body.innerHTML = "xxxxxxx";
</script>
</Body>