Load magnific popup on page load

。_饼干妹妹 提交于 2019-12-11 09:09:46

问题


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)

回答1:


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);


来源:https://stackoverflow.com/questions/29206728/load-magnific-popup-on-page-load

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