本文介绍了在页面加载时加载大量弹出窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个网站,想要在有人打开页面时显示YouTube视频(延迟5秒)。

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.

这是可行的代码(感谢@Yoink!)

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)


推荐答案

它正在运行,你将这个巨大的弹出窗口绑定到班级。如果您要将div更改为锚链接,它将打开。

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

这篇关于在页面加载时加载大量弹出窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-30 23:54