使用 jQuery 添加页面加载器 [英] Adding a page loader using jQuery

查看:25
本文介绍了使用 jQuery 添加页面加载器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一点帮助.我不知道从哪里开始.我需要向我的网站添加一个页面加载器.我首先提交一个表单,然后它使用 SimpleXML 调用带有 expedia 的外部 XML 表...加载需要一分钟,所以我想将图像加载器添加到此页面.但是我该怎么做呢?我在 Google 上搜索过,但找不到任何有用的信息.

I need a little help. I do not know where to start. I need to add a page loader to my website. I first submit a form it then uses SimpleXML to call an exterior XML Sheet with expedia... It takes a minute to load, so I would like to add the image loader to this page. But how do I go about doing this? I have looked on Google and could not find any useful info.

我需要它来显示加载器,直到完成页面加载完毕.

I need it to show the loader until the COMPLETE page has loaded.

推荐答案

这有很多解决方案,但最简单的一个是:

This has many solutions, but a simple one is to:

1- 用你的加载程序创建一个覆盖 DIV 并添加到 BODY;
2- 为隐藏此 DIV 的 window.loaddocument.ready 事件添加事件侦听器.

1- Create an overlay DIV with your loader stuff and prepend to BODY;
2- Add an event listener for window.load or document.ready event that hides this DIV.

// On the first line inside BODY tag
<script type="text/javascript">
    jQuery("body").prepend('<div id="preloader">Loading...</div>');
    jQuery(document).ready(function() {
        jQuery("#preloader").remove();
    });
</script>

(代码错别字已修复)

这篇关于使用 jQuery 添加页面加载器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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