Results 1 to 9 of 9

Thread: Targeting a div in the parent window with a floating IFRAME

  1. #1
    Join Date
    Jan 2007
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Targeting a div in the parent window with a floating IFRAME

    Hi There,

    I'm using a script on my page that pops up a floating window. The window is a div tag with a nested iframe, the IFRAME content is loaded with an SRC....

    Inside that window I am sometimes using AJAX calls to send info and forms that I want to have updated inside another DIV tag on the main page. I have tried using all kinds of 'parent.divid' combos in the target field of my AJAX function, but nothing works.

    My Question: How do I identify an element that is outside the floating IFRAME in the Javascript function call?

    I hope I haven't asked a really obvious question... I've been searching these forums and the rest of the net to no avail.

    Cheers,

    Greg.

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    If you are running a script inside an iframe that has had its content altered via Ajax, that script may not even be properly initialized. If that isn't an issue, the Ajax loaded content will act exactly as if it were hard coded onto the page that is displaying in an iframe. The easiest way to pick up an element in the parent window is to assign it as a global variable on the parent page:

    Code:
    var var_name=document.getElementById('myElementId');
    and then to access it from the child page as:

    Code:
    parent.var_name
    You can even go straight to:

    Code:
    parent.document.getElementById('myElementId')
    Last edited by jscheuer1; 01-13-2007 at 06:32 PM.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Jan 2007
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Hi John,

    The content has been loaded in a page altered by ajax.... any suggestions as to how to make sure its initialized properly?

    Greg.

  4. #4
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Quote Originally Posted by kasper48 View Post
    Hi John,

    The content has been loaded in a page altered by ajax.... any suggestions as to how to make sure its initialized properly?

    Greg.
    I'd have to see it to really tell. As I implied, this may or may not be an issue, it depends upon what type of content it is and what if any type(s) of scripts it deals with and, if any - where those scripts are. Can you supply a link to your page?
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  5. #5
    Join Date
    Jan 2007
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Hi John,

    I sent a link to the page to your email... I'm starting to do my reading on the DOM and setting variables.... this is where the solution lies most likely, no?

    Greg.

  6. #6
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    OK, I see the floating iframe. I don't see content being loaded into that iframe via Ajax, what do I need to do to see that? I may just of missed it.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  7. #7
    Join Date
    Jan 2007
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    So when the window is open labeled 'define your course' when you type in codes such as 'P' then 'O' it will load up content (links) with some pretty standard autocomplete jazz.

    Those links are the ones that I am trying to target the response of, back to the main parent page. Right now I have the response coming right into the window (it should load 'POLI 101 // //' or whichever course code you click) below the link itself...

    hope this is coherent

    Greg.

  8. #8
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    How do I get to that window? Anyways, if it is coming into the window itself, it should just about as easily be able to go to the parent window.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  9. #9
    Join Date
    Jan 2007
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I solved the problem by getting rid of the IFRAME completely...

    It was loading the contents with an SRC and I guess that meant I lost the stuff stored in the DOM?

    I'm self taught and feeling my way through this.

    Thanks for keeping me in the right direction.

    Greg

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
  •