• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

14. Creating Dynamic Content > 14.12. Inserting and Populating an iframe Elemen...

Inserting and Populating an iframe Element

NN 6, IE 5

Problem

You want to create an iframe element, insert it into the current document, and place content into the iframe.

Solution

This task requires a little more than just creating elements and appending them to the document. This is a case in which one of the elements you create—an iframe—requires a document tree context before you can stuff it with data. The following code takes place in the global space. If you bury it inside a function, predeclare the newIframe variable as a global.

First, we are going to append an iframe to the end of the body element, and then we will put a dynamically generated form into the iframe. Begin the expected way, by creating the iframe element in memory, and inserting the empty iframe into the document:


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint