对以编程方式打开的fancybox iframe进行样式化

Styling a fancybox iframe that is opened programatically

本文关键字:iframe 样式 fancybox 编程 方式打      更新时间:2023-09-26

我可以用下面的代码块样式化fancybox iframe链接:

$("#fancy").fancybox({
    type        : 'iframe',
    maxWidth    : 800,
    maxHeight   : 600,
    fitToView   : false,
    width       : '600px',
    height      : '590px',
    autoSize    : false,
    closeClick  : false,
    openEffect  : 'none',
    closeEffect : 'none'
});

应用于fancybox iframe link:

<a id="fancy" data-fancybox-type="iframe" href="includes/schedule.php">link</a> 

我遇到的问题是,相同的是不工作的一个fancybox iframe链接,我以编程方式打开,在以下脚本中:

<script type="text/javascript">
    $(document).ready(function() {
        $('.submit').click(function() {
            var email = $(this).val()
            var varData = '&email=' + email;
            document.getElementById('beep').play();
            $.ajax({
                   type: "POST",
                    url:'mailer.php',
                   data: varData,
                success: function() {
                    javascript:parent.$.fancybox.open({href : 'includes/thankyou.php', id: 'thanky', type: 'iframe'});
                }
            });
        });
    });
</script>   

iframe是用fancybox打开的,但是在这种情况下没有应用样式。

提前感谢您的帮助。

将此添加到thankyou.php页面末尾的body元素

<script type="text/javascript"> 
 $(document).ready(function() {
       $("#fancy").fancybox({
        type        : 'iframe',
         maxWidth    : 800,
         maxHeight   : 600,
         fitToView   : false,
         width       : '600px',
         height      : '590px',
         autoSize    : false,
         closeClick  : false,
         openEffect  : 'none',
         closeEffect : 'none'
     });
});
 </script>