iframe

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

    iframe

    I have an iframe (IE5):

    <iframe name="frame1" id="frame1" src="some_sourc e">test</iframe>

    that test appears outside the iframe, the src contents are in the iframe
    though

    I'd like to read the iframe.

    var frame1=document .getElementById ('frame1').inne rHTML;

    What I get is "test", not what the contents of the iframe actually is.

    What have I done wrong?

    Jeff
  • Lasse Reichstein Nielsen

    #2
    Re: iframe

    Jeff Thies <cyberjeff@spri ntmail.com> writes:
    [color=blue]
    > I have an iframe (IE5):
    >
    > <iframe name="frame1" id="frame1" src="some_sourc e">test</iframe>
    >
    > that test appears outside the iframe, the src contents are in the iframe
    > though
    >
    > I'd like to read the iframe.
    >
    > var frame1=document .getElementById ('frame1').inne rHTML;
    >
    > What I get is "test", not what the contents of the iframe actually is.
    >
    > What have I done wrong?[/color]

    You want to access the content page in the frame. That is a completely
    different page, so its HTML is not part of the iframe element on this
    page.

    What you can do is either:

    var frame1=document .getElementById ('frame1');
    var iframeDocument = frame1.contentW indow ? frame1.contentW indow.document
    : frame1.contentD ocument;
    var root = iframeDocument. documentElement || iframeDocument. body;
    var HTML = root.innerHTML;

    or

    var frame1Document = frames['frame1'].document;
    var root = iframeDocument. documentElement || iframeDocument. body;
    var HTML = root.innerHTML;

    /L
    --
    Lasse Reichstein Nielsen - lrn@hotpop.com
    Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit. html>
    'Faith without judgement merely degrades the spirit divine.'

    Comment

    Working...