Changing the outerHTML of an Iframe

Discussion in 'HTML' started by David Virgil Hobbs, Apr 11, 2006.

  1. I discovered how to write out the inner HTML of the contents of an
    Iframe; I want to know how to write out the outerHTML of the contents
    of an Iframe.

    frames['iframeid'].document.body.innerHTML allows me to read the inner
    HTML of the contents of an iframe and also allows me to write out the
    inner HTML of the contents of an iframe.

    However using frames['iframeid'].document.body.innerHTML I am only able
    to change, in the contents of the iframe, the code in between and
    including the body tags; I am not able to change the code above the
    body tag such as what is in the head section and what is in the html
    tag.

    The problem is, that other maneuvers that allow me to read the contents
    of an iframe, do NOT allow me to write out the contents of the iframe.
    These are:

    frames['framid'].document.body.outerText
    frames['framid'].document.body.innerText
    frames['framid'].document.documentElement.outerHTML

    The problem persists if the page originally loaded into the iframe
    contains no code.

    This looks like an unpredictable inconsistency of the type that makes
    Javascript a language to be learned through experimentation. Or is
    there some documentation somewhere that lists the read/write abilities
    of such lines of code?
     
    David Virgil Hobbs, Apr 11, 2006
    #1
    1. Advertising

  2. David Virgil Hobbs

    Danny Guest

    Well, outerHTML is IE only for one, and from msnd kb ->

    Applies To
    A, ACRONYM, ADDRESS, APPLET, AREA, B, BDO, BGSOUND, BIG, BLOCKQUOTE,
    BR, BUTTON, CAPTION, CENTER, CITE, CODE, COL, COLGROUP, CUSTOM, DD,
    DEL, DFN, DIR, DIV, DL, DT, EM, EMBED, FIELDSET, FONT, FORM,
    FRAMESET, hn, HR, HTML Comment, HTML, I, IFRAME, IMG, INPUT
    type=button, INPUT type=checkbox, INPUT type=file, INPUT type=hidden,
    INPUT type=image, INPUT type=password, INPUT type=radio, INPUT
    type=reset, INPUT type=submit, INPUT type=text, INS, KBD, LABEL,
    LEGEND, LI, LISTING, MAP, MARQUEE, MENU, nextID, NOBR, OBJECT, OL, P,
    PLAINTEXT, PRE, Q, RT, RUBY, S, SAMP, SELECT, SMALL, SPAN, STRIKE,
    STRONG, SUB, SUP, TABLE, TBODY, TD, TEXTAREA, TFOOT, TH, THEAD, TR,
    TT, U, UL, VAR, WBR, XMP
    ----------------------------------
    The property is read/write for all objects except the following, for
    which it is read-only: CAPTION, COL, COLGROUP, FRAMESET, HTML, TBODY,
    TD, TFOOT, TH, THEAD, TR. The property has no default value.

    It doesn't include BODY.

    Danny
     
    Danny, Apr 11, 2006
    #2
    1. Advertising

  3. David Virgil Hobbs

    Neredbojias Guest

    To further the education of mankind, "David Virgil Hobbs"
    <> declaimed:

    > I discovered how to write out the inner HTML of the contents of an
    > Iframe; I want to know how to write out the outerHTML of the contents
    > of an Iframe.


    The last time I checked, outerHTML didn't work in most of my browsers.

    --
    Neredbojias
    Infinity can have limits.
     
    Neredbojias, Apr 11, 2006
    #3
  4. David Virgil Hobbs wrote:
    > However using frames['iframeid'].document.body.innerHTML I am only able
    > to change, in the contents of the iframe, the code in between and
    > including the body tags; I am not able to change the code above the
    > body tag such as what is in the head section and what is in the html
    > tag.


    Instead of using innerHTML you may create a new document and use
    document.write()

    You may also access the head element by using DOM methods like:
    var htmlElm = document.documentElement;
    var headElm = htmlElm.getElementsByTagName("head")[0];

    But what are you trying to do in the head?
    To change the title, you may use
    document.title = "foo";

    Daniel
     
    Daniel Kirsch, Apr 11, 2006
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. schapopa

    OuterHTML - loosing polish fonts

    schapopa, Jan 24, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    339
    schapopa
    Jan 24, 2005
  2. schapopa

    OuterHTML - loosing polish fonts

    schapopa, Jan 24, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    377
    schapopa
    Jan 24, 2005
  3. John Kotuby

    outerHTML not working in Firefox

    John Kotuby, Jun 27, 2007, in forum: ASP .Net
    Replies:
    4
    Views:
    8,445
    bruce barker
    Jun 27, 2007
  4. Aron
    Replies:
    1
    Views:
    96
    kaeli
    Jul 9, 2003
  5. Daedalous
    Replies:
    3
    Views:
    718
    Daedalous
    Jan 16, 2004
Loading...

Share This Page