如何在html中获取延迟加载效果到整页? [英] how to get lazy load effect to full page in html?

查看:158
本文介绍了如何在html中获取延迟加载效果到整页?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将Lazy加载效果发送到我的网站。

I am trying to get Lazy load effect to my website.

在这里,我的网站包含一个长页面...其中有5个部分。
这里,为了用户体验,我需要在用户在我的网站滚动时加载这些部分,然后我只需要将这些部分加载到我的主页。

Here, My website is consisting a long page.. which has 5 sections. Here, for user experience i need to load the sections when user scroll in my website then only i need to load those sections to my homepage.

注意:在我的网站上,所有数据都是静态的。

是否可以。?

我知道这是可能的。我看到了一些这样的网站。

i know it is possible. I saw some websites like that.

但是我不知道能不能实现这个功能。

But i have no idea to achieve this functionality.?

建议更好这样做的方法。?

Suggest Better way to do this.?

推荐答案

例如当使用 jQuery 时你可以使用如下所示的onscroll处理程序。

For example when using jQuery you could use an onscroll handler like the following one.

$(document).scroll(function() {

});

然后此函数使用 scrollTop 确定垂直滚动位置,并根据定义的偏移量使AJAX请求获取内容。

And this function then uses scrollTop to determine the vertical scroll position and on defined offsets it makes AJAX requests to get the content.

这篇关于如何在html中获取延迟加载效果到整页?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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