...

View Full Version : help with onLoad function



slornitzo
06-16-2010, 04:57 PM
I have a popup window that calls a texteditor. I want the texteditor to show the inner HTML of the parent doucument by div id.
When I call the function through a submit (in child window) it workks great, but I want innerHTML to be added when child page loads.
I have tried calling function in body onLoad=getparent;
tries adding it to inner script where it calls the editor , again onLoad=getparent;
Tried with and without () i.e onLoad=getparent();

Child window code:

[code]
<html>
<head>
<title>Mangae Content</title>
<script type="text/javascript" src="/ckeditor/ckeditor.js"></script>


<script language="javascript">


function getparent()
{
var TextToPass = window.opener.document.getElementById('missionStatement');
var TextToEdit = TextToPass.innerHTML;
document.getElementById('editor1').value=TextToEdit;
}


</script>

</head>
<body>



<form method="post" name="editedcontent">
<p>
My Editor:<br />
<textarea name="editor1" id="editor1"></textarea>

<script type="text/javascript">
onload=getparent;
CKEDITOR.replace( 'editor1' );
</script>

</p>
<p>
<input type="submit" onClick="getparent();"/>
</p>
</form>


</body>
</html>
[code]

When I use the submit button it works fine. Captures parent window HTML and loads it into ckeditor, How do I get it to load without using the submit button???

Any help would be greatly appreciated.

mehere8
06-16-2010, 05:09 PM
'onload' is only valid for body/frame/img tag. if you put it in between tags, it may not work as expected

you can do like this <body onload="getparent()"></body>

slornitzo
06-16-2010, 05:26 PM
Yes , I tried it in the <body > tag..

Weirder still is if I use this code

[code]
<html>
<head>
<title>Mangae Content</title>
<script type="text/javascript" src="/ckeditor/ckeditor.js"></script>


<script language="javascript">


function getparent()
{
var TextToPass = window.opener.document.getElementById('missionStatement');
var TextToEdit = TextToPass.innerHTML;
document.getElementById('editor1').value=TextToEdit;

}


function post_value(){
opener.document.getElementById('missionStatement').innerHTML = document.editedcontent.editor1.value;
self.close();
}



</script>

</head>
<body>



<form method="post" name="editedcontent">
<p>
My Editor:<br />
<textarea name="editor1" id="editor1"></textarea>

<script type="text/javascript">
onload=getparent;
CKEDITOR.replace( 'editor1' );
</script>

</p>
<p>
<input type="submit" onClick="post_value();" value="Save"/>
<input type="submit" onClick="getparent();" value="get content"/>
</p>
</form>


</body>
</html>
[code]

with the onLoad inside the script tags before ckeditor call I can get it to load the innerHTML using the getcontent submit button... (Of course I don't want to have to have to use this button)

BUT if I simply delete that onLoad code.. the submit button doesn't work anymore to get the innerHTML??



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum