SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Zealot
    Join Date
    Apr 2004
    Location
    next to a pc connected to the poweroutlet
    Posts
    126
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    IFrame and Loading Content

    Im trying to get my Iframe to add content when required using this simple bit of code, this is just a snippet of what Im using however the rest of the code doesnt affect this.

    Code:
      document.getElementsByTagName("iframe")[0].document.body.innerHTML = "testing";
    Basically when this line is executed the "testing" instead of being in the IFRAME the IFRAME becomes the main window and then testing is displayed. Is there away to make it just add the text without the IFRAME breaking?

  2. #2
    CSS & JS/DOM Adept bronze trophy
    Join Date
    Mar 2005
    Location
    USA
    Posts
    5,482
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try this.
    Code:
    document.getElementsByTagName("iframe")[0].contentWindow.document.body.innerHTML = "testing";
    To get it to work in IE5.0/Win, you'll need to use window.frames[] instead.

    http://forums.devshed.com/t261202/s.html
    We miss you, Dan Schulz.
    Learn CSS. | X/HTML Validator | CSS validator
    Dynamic Site Solutions
    Code for Firefox, Chrome, Safari, & Opera, then add fixes for IE, not vice versa.


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
  •