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 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Sep 2006
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    innerHTML of Iframe in parent

    I have a page, with 3 IFRAMEs on it. From one of these IFRAMES, i am trying to append to the content of another IFRAME.

    This doesnt work:
    top.frames[0].document.getElementByID('chat').innerHTML+= "new content"

    any thoughts?

    I know I'm referring to the right frame, because

    top.frames[0].document.location.href = "someotherpage.html"

    does work

  • #2
    New Coder
    Join Date
    Aug 2006
    Location
    Illinois
    Posts
    68
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I'm not positive, but I don't think you can append content using innerHTML. I think it wipes out everything that was previously there. Another way to accomplish what you're wanting is to try this:

    Code:
    var strContent = top.frames[0].document.getElementByID('chat').innerHTML + "new content";
    top.frames[0].document.getElementByID('chat').innerHTML = strContent;
    Sarah

  • #3
    Banned
    Join Date
    May 2006
    Location
    England
    Posts
    664
    Thanks
    0
    Thanked 84 Times in 84 Posts
    Quote Originally Posted by agentforsythe View Post
    I have a page, with 3 IFRAMEs on it. From one of these IFRAMES, i am trying to append to the content of another IFRAME.

    This doesnt work:
    top.frames[0].document.getElementByID('chat').innerHTML+= "new content"

    any thoughts?
    Any error messages in the console?
    Does this code run at load time, or after all frames are definitely loaded?

  • #4
    Senior Coder
    Join Date
    Aug 2002
    Location
    UK
    Posts
    2,789
    Thanks
    2
    Thanked 14 Times in 14 Posts
    You have a typo in this line, maybe thats the problem

    top.frames[0].document.getElementByID('chat').innerHTML+= "new content"


    top.frames[0].document.getElementById('chat').innerHTML+= "new content"
    The silent one.

    The most dangerous thing in the world is an idea.
    The most dangerous person in the world is the one with an idea.


  •  

    Posting Permissions

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