答案 0 :(得分:25)
如果您正在使用jQuery,您可以只是监听窗口加载事件,然后调用Magnific Popup的open方法,如下所示:
(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);
答案 1 :(得分:10)
我能够使用jquery的setTimeout函数获得定时模式,只需在settimeout函数中包装.magificpopup来设置延迟。将值5000(5秒)更改为您想要的任何值。
见下文:
$(document).ready(function () {
setTimeout(function() {
if ($('#myModal').length) {
$.magnificPopup.open({
items: {
src: '#myModal'
},
type: 'inline'
});
}
}, 5000);
});