我怎样才能让它在页面加载后立即运行?

发布于 2025-01-06 03:32:38 字数 724 浏览 2 评论 0原文

我希望这个 fancyBox 在页面加载后立即运行,而不必单击图像。

在 javascript 代码中我有:

<script type="text/javascript">
        $(document).ready(function() {

    $(".fancybox").fancybox({

                type : 'image',
                maxWidth    : 800,
                padding     : 0,
                fitToView   : true,
                maxHeight   : 600,
                fitToView   : false,
                width       : '70%',
                height  : '70%',
                autoSize    : true,
                closeClick  : false,
                nextEffect  : 'none',
                closeEffect : 'none',
                mousewheel : true

        });
        });
    </script>

谢谢大家!

I want this fancyBox to run as soon as the page has loaded instead of having to click on a image.

In the javascript code i have:

<script type="text/javascript">
        $(document).ready(function() {

    $(".fancybox").fancybox({

                type : 'image',
                maxWidth    : 800,
                padding     : 0,
                fitToView   : true,
                maxHeight   : 600,
                fitToView   : false,
                width       : '70%',
                height  : '70%',
                autoSize    : true,
                closeClick  : false,
                nextEffect  : 'none',
                closeEffect : 'none',
                mousewheel : true

        });
        });
    </script>

Thanks Guys!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

意中人 2025-01-13 03:32:38

假设 .fancybox 是有问题的图像,则 $(".fancybox").click() 位于 $(document).ready(function() { 的末尾>

Assuming that .fancybox is the image in question, $(".fancybox").click() at the end of your $(document).ready(function() {

随风而去 2025-01-13 03:32:38

文档 中:

jQuery(document).ready(function() {
  $("#your_selector").trigger('click');
});

其中 your_selector 附加了一个 fancybox,所以在您的情况下,将是.fancybox

From the documentation:

jQuery(document).ready(function() {
  $("#your_selector").trigger('click');
});

Where your_selector has a fancybox attached to it, so in your case this would be .fancybox.

云柯 2025-01-13 03:32:38

你可以尝试一个肮脏的黑客,

$(document).ready(function() {

    $(".fancybox").fancybox({

                type : 'image',
                maxWidth    : 800,
                padding     : 0,
                fitToView   : true,
                maxHeight   : 600,
                fitToView   : false,
                width       : '70%',
                height  : '70%',
                autoSize    : true,
                closeClick  : false,
                nextEffect  : 'none',
                closeEffect : 'none',
                mousewheel : true

        });
 $(".fancybox").click();
        });

它看起来像是记录的方式

jQuery(document).ready(function() {
    $("#your_selector").trigger('click');
});

you can try a dirty hack

$(document).ready(function() {

    $(".fancybox").fancybox({

                type : 'image',
                maxWidth    : 800,
                padding     : 0,
                fitToView   : true,
                maxHeight   : 600,
                fitToView   : false,
                width       : '70%',
                height  : '70%',
                autoSize    : true,
                closeClick  : false,
                nextEffect  : 'none',
                closeEffect : 'none',
                mousewheel : true

        });
 $(".fancybox").click();
        });

it seems like its the documented way

jQuery(document).ready(function() {
    $("#your_selector").trigger('click');
});
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文