在开始幻灯片放映之前,JQuery是否等待页面完成加载? [英] JQuery wait for page to finish loading before starting the slideshow?

查看:116
本文介绍了在开始幻灯片放映之前,JQuery是否等待页面完成加载?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有旋转标题图像的网站(你们都看过它们)。我想执行以下操作:

I have a site with a rotating header image (you've all seen them). I want to do the following:


  1. 加载整个页面加上第一个标题图像

  2. 开始标题图片幻灯片每隔x秒转换一次或下一张图片加载完毕后,以较晚者为准

我真的不需要真正做到这一点的例子。

I haven't really need an example that truly does this.

推荐答案

你可能已经知道$(document).ready(...)。你需要的是一个预加载机制;在显示数据之前获取数据(文本或图像或其他)的东西。这可以使网站感觉更专业。

You probably already know about $(document).ready(...). What you need is a preloading mechanism; something that fetches data (text or images or whatever) before showing it off. This can make a site feel much more professional.

看看 jQuery.Preload (还有其他)。 jQuery.Preload有几种触发预加载的方式,并且还提供回调功能(当图像被预加载时,然后显示它)。我已经大量使用它了,效果很好。

Take a look at jQuery.Preload (there are others). jQuery.Preload has several ways of triggering preloading, and also provides callback functionality (when the image is preloaded, then show it). I have used it heavily, and it works great.

这是开始使用jQuery.Preload的简单方法:

Here's how easy it is to get started with jQuery.Preload:

$(function() {
  // First get the preload fetches under way
  $.preload(["images/button-background.png", "images/button-highlight.png"]);
  // Then do anything else that you would normally do here
  doSomeStuff();
});

这篇关于在开始幻灯片放映之前,JQuery是否等待页面完成加载?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆