Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Jun 2010
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    help with onLoad function

    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.

  • #2
    Regular Coder
    Join Date
    Dec 2009
    Posts
    108
    Thanks
    22
    Thanked 2 Times in 2 Posts
    '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>

  • #3
    New to the CF scene
    Join Date
    Jun 2010
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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??


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •