Bru*_*mes 15 html javascript jquery magnific-popup
我正在使用Magnific Popup,我想在页面加载弹出窗口后立即显示视频.
我让插件工作正常,但我不知道如何在页面加载时立即弹出它,而不点击缩略图.
我四处寻找解决方案,但我没有设法让它发挥作用.
小智 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);
Run Code Online (Sandbox Code Playgroud)
小智 10
我能够使用jquery的setTimeout函数获得定时模式,只需在settimeout函数中包装.magificpopup来设置延迟.将值5000(5秒)更改为您想要的任何值.
见下文:
$(document).ready(function () {
setTimeout(function() {
if ($('#myModal').length) {
$.magnificPopup.open({
items: {
src: '#myModal'
},
type: 'inline'
});
}
}, 5000);
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
36648 次 |
| 最近记录: |