spec/helpers/dom-utils.js
function createIframe ( opts ) {
    var parent = ( opts && opts.parent ) ? ( varExists( $ ) && opts.parent instanceof $ ) ? opts.parent[0] : opts.parent : document.body,
        _document = parent.ownerDocument,
        iframe = _document.createElement( "iframe" );

    opts || ( opts = {} );

    if ( opts.elementStyles ) iframe.style.cssText = ensureTrailingSemicolon( opts.elementStyles );
    iframe.frameborder = "0";

    if ( opts.prepend ) {
        parent.insertBefore( iframe, parent.firstChild );
    } else {
        parent.appendChild( iframe );
    }

    iframe.src = 'about:blank';
    createIframeDocument( iframe, opts.documentStyles );

    return iframe;
}
function createIframe ( opts ) {
    var parent = ( opts && opts.parent ) ? ( varExists( $ ) && opts.parent instanceof $ ) ? opts.parent[0] : opts.parent : document.body,
        _document = parent.ownerDocument,
        iframe = _document.createElement( "iframe" );

    opts || ( opts = {} );

    if ( opts.elementStyles ) iframe.style.cssText = ensureTrailingSemicolon( opts.elementStyles );
    iframe.frameborder = "0";

    if ( opts.prepend ) {
        parent.insertBefore( iframe, parent.firstChild );
    } else {
        parent.appendChild( iframe );
    }

    iframe.src = 'about:blank';
    createIframeDocument( iframe, opts.documentStyles );

    return iframe;
}
function createIframe ( opts ) { var parent = ( opts && opts . parent ) ? ( varExists ( $ ) && opts . parent instanceof $ ) ? opts . parent [ 0 ] : opts . parent : document . body , _document = parent . ownerDocument , iframe = _document . createElement ( "iframe" ) ; opts || ( opts = { } ) ; if ( opts . elementStyles ) iframe . style . cssText = ensureTrailingSemicolon ( opts . elementStyles ) ; iframe . frameborder = "0" ; if ( opts . prepend ) { parent . insertBefore ( iframe , parent . firstChild ) ; } else { parent . appendChild ( iframe ) ; } iframe . src = 'about:blank' ; createIframeDocument ( iframe , opts . documentStyles ) ; return iframe ; }
Creates an iframe with an HTML5 doctype and UTF-8 encoding. Appends it to the body, or to another specified parent
element. Alternatively, the iframe can be prepended to the parent.

The iframe element can be styled as it is created, before it is added to the DOM, e.g. to keep it out of view.
Likewise, styles can be written into the iframe document as it is created, providing it with defaults from the
get-go.

@param   {Object}             [opts]
@param   {HTMLElement|jQuery} [opts.parent=document.body]  the parent element to which the iframe is appended
@param   {boolean}            [opts.prepend=false]         if true, the iframe gets prepended to the parent, rather than appended
@param   {string}             [opts.elementStyles]         cssText string, styles the iframe _element_
@param   {string}             [opts.documentStyles]        cssText string of entire rules, styles the iframe document, e.g.
"html, body { overflow: hidden; } div.foo { margin: 2em; }"
@returns {HTMLIFrameElement}
Creates an iframe with an HTML5 doctype and UTF - 8 encoding . Appends it to the body or to another specified parent element . Alternatively the iframe can be prepended to the parent .