用户到达底部时如何加载新页面/URL [英] How to load a new page/url when user reach the bottom

查看:72
本文介绍了用户到达底部时如何加载新页面/URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建无限负载,这意味着当用户到达页面/特定div的底部时,将加载一个新页面. 目前,我有此代码可以在点击时加载新页面.

I am creating infinite load,means a new page gets loaded when user reach bottom of the page/particular div. Currently i have this code to load new page on click.

$("#about").click(function(){
    // load about page on click
        $("#response").load("about.html");
    });

这里的任何人对如何在不单击/到达底部的情况下加载新页面有更清晰的认识

Does anyone here have more clear idea of how to load new page without click/reaching a bottom

推荐答案

您可以根据鼠标窗口位置发送ajax调用.

You can send the ajax call based on mouse window position.

 var no=1;
    $(window).scroll(function () {
        if(no==1)
        {
            if ($(window).height() + $(window).scrollTop() == $(document).height()) {
                no=2;
                $.ajax({
                    type: "POST",
                    url: "about.html",
                    data: datas,
                    cache: false,
                    success: function(html){

                    }
                });
            }
        }
    });

此ajax调用将在用户到达页面末尾时调用.您可以指定它发生的高度.

This ajax call will call when a user reaches at end of page. You can specify a height at which it occurs.

这篇关于用户到达底部时如何加载新页面/URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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