Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Smokes a Lot
    Join Date
    Jul 2003
    Location
    CA, USA
    Posts
    1,594
    Thanks
    5
    Thanked 20 Times in 20 Posts

    How do you write text to an inline frame?

    I've tried this among others -

    document.getElementById('pane').document.write("hello");



    <iframe src="blank.html" id="pane" height="300" width="600"></iframe>

    Nothing seems to be working is it possible?

    Thanks -
    Basscyst
    Last edited by Basscyst; 09-27-2003 at 11:19 PM.

  • #2
    Smokes a Lot
    Join Date
    Jul 2003
    Location
    CA, USA
    Posts
    1,594
    Thanks
    5
    Thanked 20 Times in 20 Posts
    Ahh I fingered it out you have to open it to write to it. Thanks anyway.

    window.pane.document.open();
    window.pane.document.write("Hello");
    window.pane.document.close();

  • #3
    Regular Coder
    Join Date
    Aug 2003
    Posts
    383
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Not really. document.write() automatically calls document.open() (and document.clear()) on a closed document. Your first attempt wasn't working because .getElementById() returns the element object, which doesn't have a document property. The second attempt uses a frame reference (same as window.frames.frame_name), returning the window object representing the iframe, which has the iframe's document object (like all window objects) as a property. Might try:
    Code:
    function IFRAME_write(iframe_id, HTML)
    {
         var IFrameDoc, oIframe = document.getElementById(iframe_id);
         if (typeof oIframe != 'undefined')
         {
              if (oIframe.contentDocument) 
                   IFrameDoc = oIframe.contentDocument; 
              else if (oIframe.contentWindow) 
                   IFrameDoc = oIframe.contentWindow.document;
              else if (oIframe.document) 
                   IFrameDoc = oIframe.document;
              if (IFrameDoc)
              {
                   IFrameDoc.write(HTML);
                   IFrameDoc.close();
              }
         }
    }
    Last edited by cheesebag; 09-28-2003 at 12:12 AM.
    &nbsp;........ another wild guess ........

  • #4
    Smokes a Lot
    Join Date
    Jul 2003
    Location
    CA, USA
    Posts
    1,594
    Thanks
    5
    Thanked 20 Times in 20 Posts
    Understood. Thanks.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •