how to load magnific popup modal on page load

喜你入骨 提交于 2019-12-10 19:42:10

问题


I'm trying to load my magnific popup modal on page load, however I can't quite understand the syntax in the documentation. How do I call the modal on page load?

My HTML:

<div id="test-modal" class"white-popup-block mfp-hide">
    <h1>Modal Test</h1>
    <p>
    Test Some text.
    </p>
    <p>
    <a class="popup-modal-dismiss">Dismiss</a>
    </p>
</div>

My JS:

$(window).load(function(){

???? What code should I place???
});

I have already preloaded the script and css files, what do I type inside the JS to make it load the popup on load?


回答1:


Try this:

$.magnificPopup.open({
    items: {
        src: '<div id="test-modal" class="white-popup"><h1>Modal Test</h1><p>Test Some text.</p><p><a class="popup-modal-dismiss">Dismiss</a></p></div>',
        type:'inline'
    },
    modal: true
});

And the fiddle...




回答2:


$.magnificPopup.open({items: {src: '#id-of-your-popup'},type: 'inline'}, 0);



回答3:


You can try this:

    $.magnificPopup.open({
        items: {
            src: 'images/loading.gif',
            type:'image'
        },
        modal: true
    });


来源:https://stackoverflow.com/questions/20507900/how-to-load-magnific-popup-modal-on-page-load

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!