get contents of iframe

Discussion in 'HTML' started by markww, Apr 21, 2006.

  1. markww

    markww Guest

    I cannot get the contents of an iframe in my page, it is quickly
    driving me insane. My iframe is defined like:

    <iframe id = "e_body" name = "e_body" src="about:blank"></iframe>

    I've made a function to retrieve the contents like:

    function GetIFrameContentsPlease()
    {
    var strContents =
    document.getElementById("e_body").document.body.innerHTML;

    alert("the contents are: " + strContents);
    }

    but it fails. I need this to work on IE and FF, any suggestions?

    Thanks
     
    markww, Apr 21, 2006
    #1
    1. Advertising

  2. markww

    Neredbojias Guest

    To further the education of mankind, "markww" <>
    vouchsafed:

    > I cannot get the contents of an iframe in my page, it is quickly
    > driving me insane. My iframe is defined like:
    >
    > <iframe id = "e_body" name = "e_body" src="about:blank"></iframe>
    >
    > I've made a function to retrieve the contents like:
    >
    > function GetIFrameContentsPlease()
    > {
    > var strContents =
    > document.getElementById("e_body").document.body.innerHTML;
    >
    > alert("the contents are: " + strContents);
    > }
    >
    > but it fails. I need this to work on IE and FF, any suggestions?


    You realize you do need an actual source (-html document) in order to get
    the contents of the iframe? I don't know if "about:blank" does it.

    With that in mind, try this:

    setTimeout("alert(e_body.document.body.innerHTML);",10);

    --
    Neredbojias
    Infinity has its limits.
     
    Neredbojias, Apr 21, 2006
    #2
    1. Advertising

  3. markww

    markww Guest

    Hi,

    Yes there is no initial content, but the user is allowed to type in the
    iframe with designMode = 'on' - I just need to get whatever they have
    typed into the iframe. I'll give what you posted a try,

    Thanks
     
    markww, Apr 21, 2006
    #3
  4. markww wrote:
    > Hi,
    >
    > Yes there is no initial content, but the user is allowed to type in the
    > iframe with designMode = 'on' - I just need to get whatever they have
    > typed into the iframe. I'll give what you posted a try,
    >
    > Thanks
    >

    If I understand you correctly you are using an IFRAME to get user input?
    HTML already contains an element for such purpose, it is a FORM with a
    TEXTAREA. Why the re-engineering?

    --
    Take care,

    Jonathan
    -------------------
    LITTLE WORKS STUDIO
    http://www.LittleWorksStudio.com
     
    Jonathan N. Little, Apr 21, 2006
    #4
  5. markww

    markww Guest

    Hi Jonathan,

    I wanted to use an iframe so that the user could do some limited rich
    text formatting, and I wouldn't have to script anything extra. I would
    like there to be a button beneath the iframe such as 'edit' - in which
    case the user can start typing in there, make text bold, type weblinks
    like www.something.com. Then they could just hit 'stop edit', in which
    case I'd just turn design mode 'off' and the weblinks they typed become
    active, the rich text maintains its formatting, etc.

    All I'd have to do is flip the designMode switch.

    Textareas as I understand don't allow for such formatting or clickable
    links?

    Thanks

    Jonathan N. Little wrote:
    > markww wrote:
    > > Hi,
    > >
    > > Yes there is no initial content, but the user is allowed to type in the
    > > iframe with designMode = 'on' - I just need to get whatever they have
    > > typed into the iframe. I'll give what you posted a try,
    > >
    > > Thanks
    > >

    > If I understand you correctly you are using an IFRAME to get user input?
    > HTML already contains an element for such purpose, it is a FORM with a
    > TEXTAREA. Why the re-engineering?
    >
    > --
    > Take care,
    >
    > Jonathan
    > -------------------
    > LITTLE WORKS STUDIO
    > http://www.LittleWorksStudio.com
     
    markww, Apr 21, 2006
    #5
  6. markww wrote:
    > Hi Jonathan,
    >
    > I wanted to use an iframe so that the user could do some limited rich
    > text formatting, and I wouldn't have to script anything extra. I would
    > like there to be a button beneath the iframe such as 'edit' - in which
    > case the user can start typing in there, make text bold, type weblinks
    > like www.something.com. Then they could just hit 'stop edit', in which
    > case I'd just turn design mode 'off' and the weblinks they typed become
    > active, the rich text maintains its formatting, etc.


    Many rich text widgets out there, here is one:

    http://dojotoolkit.org/docs/rich_text.html
    Rich Text Editing With Dojo
    --
    Take care,

    Jonathan
    -------------------
    LITTLE WORKS STUDIO
    http://www.LittleWorksStudio.com
     
    Jonathan N. Little, Apr 21, 2006
    #6
    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. Don Adams
    Replies:
    1
    Views:
    624
    Martin Honnen
    Mar 5, 2004
  2. Kamarulnizam Rahim
    Replies:
    4
    Views:
    246
    Robert Klemme
    Jan 28, 2011
  3. Daedalous
    Replies:
    3
    Views:
    821
    Daedalous
    Jan 16, 2004
  4. Nathan Carr
    Replies:
    0
    Views:
    293
    Nathan Carr
    Sep 17, 2004
  5. Replies:
    0
    Views:
    149
Loading...

Share This Page