SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Guru
    Join Date
    Jan 2007
    Posts
    971
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    finding the parent of an iframe with jquery

    I'm using dynamically created upload fields that are in iframes.
    (There is an "add another" button.) After uploading the file in the iframe, the file path is passed back to a hidden field in the form.

    The tricky part is passing the data back to the correct hidden field since the name can't be determined ahead of time. Passing the data through $_GET or $_POST data is highly problematic.

    So is there a way to find the div that contains the iframe from within the iframe.

    Thanks E

  2. #2
    SitePoint Member drlinux's Avatar
    Join Date
    Aug 2010
    Location
    Norway
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think you can do something like this in the iframe;

    Code JavaScript:
    var myDiv = parent.document.getElementById("myDivId");

  3. #3
    SitePoint Guru
    Join Date
    Jan 2007
    Posts
    971
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Right, the problem is the id is unknown because its created dynamically. So I was trying to find the parent element rather than the parent page.

    I figured out how to do this, though its somewhat convoluted. A function on the parent page cycles through the input fields and gathers the data. The function is triggered from inside the iframe when the upload is complete.

    E


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
  •