PDA

View Full Version : Load HTML straight into an existing <iframe>


Samji
10-01-2006, 09:15 AM
Hello, everyone.

I have this code for an <iframe>. I would like to generate the HTML dynamically to insert into this element using a function from an external JavaScript. Is this possible?


<iframe name="messagefr"
scrolling="auto" frameborder="0"
src="" height="250" width="555" flex="1"/>


Thanks in advance.

sir_plague
10-01-2006, 09:51 PM
If I'm not mistaken, you should be able to do:

messagefr.document.write('stuff here');

Samji
10-02-2006, 09:17 AM
Thanks, I worked it out.

I used...


var msgbody = parent.frames['msgframe'];
msgbody.document.open();
msgbody.document.write('<html>');
msgbody.document.write('<head>');
msgbody.document.write('<\/head>');
msgbody.document.write('<body>');
msgbody.document.write('Message body text...');
msgbody.document.write('<\/body>');
msgbody.document.write('<\/html>');
msgbody.document.close();


Thanks for your help anyway.

sir_plague
10-04-2006, 12:08 PM
Yeah, no problem. I don't do a lot with IFRAMEs, so... glad I could be of at least some assistance.

NetNessie
10-05-2006, 01:05 AM
Could I ask what you are using the IFrames for?

Samji
10-05-2006, 12:53 PM
Could I ask what you are using the IFrames for?

The message frame for my Firefox extension (http://forums.3drealms.com/vb/showthread.php?t=22408).