iframe innerHTML

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • JimMenees

    iframe innerHTML

    (code is at end of post)
    -------------------------------------------
    I'm using an i-frame to grab a server-side text file and display its content
    elsewhere in the html document. On change of the i-frame source, I want to
    access its innerHTML.

    The i-frame source changes just fine and even displays the source; the glitch
    is in accessing the innerHTML for that new i-frame src file. It requires *TWO*
    clicks of the onClick element to get the correct innerHTML (with just one
    click, the source will change, and display the new file in the html document;
    however, the innerHTML is still that of the old source file for the i-frame).


    This does not appear to be a loading problem with the new src file into the
    i-frame. (ie: setTimeout on a function to get the innerHTML after the src file
    loads does not work).

    So the question is: how can I get the i-frame source to change AND access the
    new src file's innerHTML with one click??

    Ideas, suggestions, changes appreciated.

    Thankyou,

    Jim
    ------------------- C O D E -------------------
    // framer is the new src file name for the i-frame;
    // eyeframe is the i-frame element id
    // myframe is the i-frame element name
    // centerbox inner is the div container for the new content

    function contentChange(f ramer){
    document.getEle mentById('eyefr ame').src = framer;
    document.getEle mentById('cente rboxinner').inn erHTML
    =window.frames['myframe'].document.body. innerHTML
    }
  • HikksNotAtHome

    #2
    Re: iframe innerHTML

    >From: jimmenees@aol.c omNoSpam (JimMenees)
    [color=blue]
    >I'm using an i-frame to grab a server-side text file
    >and display its content elsewhere in the html document.
    >On change of the i-frame source, I want to access its
    >innerHTML.[/color]

    Instead of trying to load it into an IFrame and then grab its
    innerHTML, why not use an HTTPRequest to simply grab
    the file, parse whats in the body, and then display it?




    --
    Randy

    Comment

    • Lasse Reichstein Nielsen

      #3
      Re: iframe innerHTML

      hikksnotathome@ aol.com (HikksNotAtHome ) writes:
      [color=blue]
      > Instead of trying to load it into an IFrame and then grab its
      > innerHTML, why not use an HTTPRequest to simply grab
      > the file, parse whats in the body, and then display it?[/color]

      Because there are more browsers supporting iframes and innerHTML
      than HTTPRequest?

      /L
      --
      Lasse Reichstein Nielsen - lrn@hotpop.com
      DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleD OM.html>
      'Faith without judgement merely degrades the spirit divine.'

      Comment

      • HikksNotAtHome

        #4
        Re: iframe innerHTML

        In article <ad5bjxii.fsf@h otpop.com>, Lasse Reichstein Nielsen <lrn@hotpop.com >
        writes:
        [color=blue]
        >hikksnotathome @aol.com (HikksNotAtHome ) writes:
        >[color=green]
        >> Instead of trying to load it into an IFrame and then grab its
        >> innerHTML, why not use an HTTPRequest to simply grab
        >> the file, parse whats in the body, and then display it?[/color]
        >
        >Because there are more browsers supporting iframes and innerHTML
        >than HTTPRequest?[/color]

        When deciding how to do something, my first thought is always to try to do it
        the most efficient way. And an HTTPRequest (where it works) is more efficient
        than loading the file into an IFrame and reading it's innerHTML property. If
        for no other reason, because you skip the browser having to render it first
        before reading it.

        But there are advantages and disadvantages to both approaches.
        --
        Randy

        Comment

        • Jim Ley

          #5
          Re: iframe innerHTML

          On 30 Dec 2003 23:33:03 GMT, hikksnotathome@ aol.com (HikksNotAtHome )
          wrote:[color=blue][color=green]
          >>Because there are more browsers supporting iframes and innerHTML
          >>than HTTPRequest?[/color]
          >
          >When deciding how to do something, my first thought is always to try to do it
          >the most efficient way. And an HTTPRequest (where it works) is more efficient
          >than loading the file into an IFrame and reading it's innerHTML property. If
          >for no other reason, because you skip the browser having to render it first
          >before reading it.[/color]

          also and in many cases more importantly for me, innerHTML in many
          browsers doesn't give you the source document you tried to load, but a
          normalised approximation of the parse tree it got from the document.
          It also runs script etc.

          Jim.
          --
          comp.lang.javas cript FAQ - http://jibbering.com/faq/

          Comment

          Working...