I use the following code to dynamically create an iframe.
var iframe_jquery = $(\"\") .addClass(\"foo\") .appendTo(container); // conta
You can also make a function that will be executed when the iframe has finished loading by setting it's onload attribute.