Note that there are some explanatory texts on larger screens.

plurals
  1. POjQuery iframe disappears after appending content
    primarykey
    data
    text
    <p>after injecting my content into an iframe within the fancybox. The frame is visible for 1 second and then disappears. That happens in chrome and firefox.</p> <p>Here ist my code:</p> <pre><code>&lt;script type="text/javascript"&gt; $(document).ready(function() { var f, txt, d, ifrmwin,edd; var getContent = function(){ return $("#iframe-content").contents().find("html").html(); }; $('.push_preview_lightbox_menu_iphone').fancybox({ type: 'iframe', onComplete: function(){ $('#fancybox-content iframe').removeAttr("src"); var $iframeWrap = $("&lt;div id=\"preview_smartphone\" style=\"margin: 0 auto; width: 550px;height:445px;\"&gt;&lt;/div&gt;") .append( $('&lt;div style=\"width: 350px;height: 445px;overflow: hidden;cursor: pointer;margin-left: 45px;\"&gt;&lt;/div&gt;') .append( $('&lt;iframe&gt;&lt;/iframe&gt;', {id: 'preview-iframe',width:"268px", height:"445px"}) ) ); eff = $('#fancybox-content iframe')[0].contentWindow.document; $("html", eff).append($iframeWrap); edd = $("#preview-iframe")[0].contentWindow.document; $("html", edd).append(getContent()); }, }); }); &lt;/script&gt; </code></pre> <p>iFrame is the same domain as the rest of the page.</p> <p>Have anybody an idea?</p> <p>THank you very much and best regards!</p> <p><strong>EDIT:</strong></p> <p>Okay..Here is the solution:</p> <pre><code>&lt;script type="text/javascript"&gt; $(document).ready(function() { var f, txt, d, ifrmwin,edd; var getContent = function(){ return $("#iframe-content").contents().find("html").html(); }; $('.push_preview_lightbox_menu_iphone').fancybox({ 'content': function() { return $('div#content').html() + '&lt;div id="preview_smartphone" style="margin: 0 auto;"&gt;' + '&lt;div style="width: 250px;height: 445px;overflow: hidden;cursor: pointer;margin-left: 45px;"&gt;' + '&lt;iframe width="268px" height="445px" id="preview-iframe" frameborder="0"&gt;' + '&lt;/iframe&gt;&lt;/div&gt;&lt;/div&gt;'; }, onComplete: function(){ eff = $('#preview-iframe')[0].contentWindow.document; $("body", eff).append(getContent()); }, }); }); &lt;/script&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload