SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Feb 2009
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    data string from parent window to popup not passed

    Strange problem, should work but it does not.

    Description:
    Inside of a page, there is a iFrame, which houses WYSIWYG editor.
    I'm trying to pass data (passedString: html, inline css, text ...) to a popup.

    Here's the relevant part of a code:

    Code:
    var winRef = ""; //global var
    
    function foo() {
    
    //open popup window
    winRef = window.open("popup.php", "blank", "toolbar=no,width=800,height=550");
    
    //passed string to a popup
    var previewData = "<div style=\"padding:5px;\">" + document.getElementById(passedString).value + "</div>";
    
    // inserting string to div in popup, which is a simple page
    // receiving div looks: <div id="idx"></div>
    winRef.document.getElementById("idx").innerHTML = previewData;
    
    }
    What I'm receiving is:
    winRef.document.getElementById("idx") is null
    When I pass same string to same div with id="idx" located on a page, where iFrame is located, it receives it without problems.
    Problem appears, when I try to pass string to popup.

    Any thoughts why?

  2. #2
    SitePoint Guru
    Join Date
    Sep 2006
    Posts
    731
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    window.open works asynchronously, so the page isn't loaded when you reference it.
    Tab-indentation is a crime against humanity.


Bookmarks

Posting Permissions

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