Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 09-27-2003, 10:14 PM   PM User | #1
Basscyst
Smokes a Lot


 
Join Date: Jul 2003
Location: CA, USA
Posts: 1,594
Thanks: 5
Thanked 20 Times in 20 Posts
Basscyst is on a distinguished road
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 10:19 PM..
Basscyst is offline   Reply With Quote
Old 09-27-2003, 10:26 PM   PM User | #2
Basscyst
Smokes a Lot


 
Join Date: Jul 2003
Location: CA, USA
Posts: 1,594
Thanks: 5
Thanked 20 Times in 20 Posts
Basscyst is on a distinguished road
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();
Basscyst is offline   Reply With Quote
Old 09-27-2003, 10:43 PM   PM User | #3
cheesebag
Regular Coder

 
Join Date: Aug 2003
Posts: 383
Thanks: 0
Thanked 0 Times in 0 Posts
cheesebag is an unknown quantity at this point
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();
          }
     }
}
__________________
&nbsp;........ another wild guess ........

Last edited by cheesebag; 09-27-2003 at 11:12 PM..
cheesebag is offline   Reply With Quote
Old 09-28-2003, 06:29 PM   PM User | #4
Basscyst
Smokes a Lot


 
Join Date: Jul 2003
Location: CA, USA
Posts: 1,594
Thanks: 5
Thanked 20 Times in 20 Posts
Basscyst is on a distinguished road
Understood. Thanks.
Basscyst is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 08:14 AM.


Advertisement
Log in to turn off these ads.