I'm working on a website, that would like to display a youtube video when someone opens the page (with a delay of 5 seconds) with magnific popup.
This is the code that works (thanks to @Yoink!)
setTimeout(function(){
$.magnificPopup.open({
items: {
src: 'http://www.youtube.com/watch?v=0O2aH4XLbto'
},
type: 'iframe'
});
}, 5000)
It is working, you're binding the magnific popup to the class. If you were to change the div to an anchor link, it would open.
If you're wanting the popup to appear on window load use the following:
$.magnificPopup.open({
items: {
src: 'http://www.youtube.com/watch?v=0O2aH4XLbto'
},
type: 'iframe'
});
For the delay, I can't see anything in the documentation for it, I may have missed it but you could do the following instead.
setTimeout(function(){
$.magnificPopup.open({
items: {
src: 'http://www.youtube.com/watch?v=0O2aH4XLbto'
},
type: 'iframe'
});
}, 5000);