- <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
- <%
- String path = request.getContextPath();
- String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
- %>
- <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
- <html>
- <head>
- <base href="<%=basePath%>">
- <title>控制页面滚动的操作 </title>
- <meta http-equiv="pragma" content="no-cache">
- <meta http-equiv="cache-control" content="no-cache">
- <meta http-equiv="expires" content="0">
- <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
- <meta http-equiv="description" content="This is my page">
- <script type="text/javascript" src="<%=basePath%>/js/jquery-1.4.4.min.js"></script>
- <script type="text/javascript">
- $(function(){
- $("#send").click(function(){
- $("#resText").load("test.html #001");
- });
- $(window).scroll(function() {
- var scrollTop = $(this).scrollTop();
- console.info("scrollTop="+scrollTop);
- var scrollHeight = $(document).height();
- console.info("scrollHeight="+scrollHeight);
- var windowHeight = $(this).height();
- console.info("windowHeight="+windowHeight);
- if (scrollTop + windowHeight == scrollHeight) {
- alert("已经到底部了!");
- //此处是滚动条到底部时候触发的事件,在这里写要加载的数据,或者是拉动滚动条的操作
- $("<div>我是div的东西吃</div>").appendTo("body");
- }
- });
- });
- </script>
- </head>
- <body>
- <ul>
- <li>1232123132</li>
- <li>1232123132</li><li>1232123132</li><li>1232123132</li><li>1232123132</li><li>1232123132</li><li>1232123132</li><li>1232123132</li><li>1232123132</li><li>1232123132</li><li>1232123132</li><li>1232123132</li>
- <li>poppoweppkd</li>
- <li>poppoweppkd</li><li>poppoweppkd</li><li>poppoweppkd</li>
- <li>poppoweppkd</li><li>poppoweppkd</li><li>poppoweppkd</li>
- </ul>
- <body>
- </body>
- </html>
- //该片段来自于http://www.codesnippet.cn/detail/2801201511671.html
来源: http://www.codesnippet.cn/detail/2801201511671.html