ファンシーボックス内のiframeにコンテンツを挿入した後。フレームは 1 秒間表示されてから消えます。それはクロムとファイアフォックスで起こります。
これが私のコードです:
<script type="text/javascript">
$(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 = $("<div id=\"preview_smartphone\" style=\"margin: 0 auto; width: 550px;height:445px;\"></div>")
.append(
$('<div style=\"width: 350px;height: 445px;overflow: hidden;cursor: pointer;margin-left: 45px;\"></div>')
.append(
$('<iframe></iframe>', {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());
},
});
});
</script>
iFrame は、ページの残りの部分と同じドメインです。
アイデアはありますか?
どうもありがとうございました。
編集:
わかりました..ここに解決策があります:
<script type="text/javascript">
$(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() + '<div id="preview_smartphone" style="margin: 0 auto;">'
+ '<div style="width: 250px;height: 445px;overflow: hidden;cursor: pointer;margin-left: 45px;">'
+ '<iframe width="268px" height="445px" id="preview-iframe" frameborder="0">'
+ '</iframe></div></div>';
},
onComplete: function(){
eff = $('#preview-iframe')[0].contentWindow.document;
$("body", eff).append(getContent());
},
});
});
</script>