如何在页面加载时打开一个巨大的弹出窗口? [英] How to open a magnific popup on page load?

查看:79
本文介绍了如何在页面加载时打开一个巨大的弹出窗口?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Magnific Popup ,我想要一个视频出现一旦页面加载弹出窗口。

I'm using Magnific Popup and I would like to have a video come up as soon as the page loads in a popup.

我让插件工作正常,但我不知道如何让它一旦弹出就可以弹出页面加载,而不点击缩略图。

I got the plugin to work fine, but I have no idea on how to get it to pop up as soon as the page loads, without clicking on the thumbnail.

我四处寻找解决方案,但我无法让它发挥作用。

I looked around for a solution, but I did not manage to get it to work.

推荐答案

如果您正在使用jQuery,您可以只是监听窗口加载事件,然后调用Magnific Popup的open方法,如下所示:

If you're using jQuery you could just listen for the window load event and then call the open method for your Magnific Popup like so:

(function($) {
    $(window).load(function () {
        // retrieved this line of code from http://dimsemenov.com/plugins/magnific-popup/documentation.html#api
        $.magnificPopup.open({
            items: {
                src: 'someimage.jpg'
            },
            type: 'image'

          // You may add options here, they're exactly the same as for $.fn.magnificPopup call
          // Note that some settings that rely on click event (like disableOn or midClick) will not work here
        }, 0);
    });
})(jQuery);

这篇关于如何在页面加载时打开一个巨大的弹出窗口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆