<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>无标题页</title>
<script type="text/javascript" src="jquery-1.8.3.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$(window).scroll(function() {
//$(document).scrollTop() 获取垂直滚动的距离
//$(document).scrollLeft() 这是获取水平滚动条的距离
if ($(document).scrollTop() <= 0) {
alert("滚动条已经到达顶部为0");
}
if ($(document).scrollTop() >= $(document).height() - $(window).height()) {
alert("滚动条已经到达底部为" + $(document).scrollTop());
}
});
});
</script>
</head>
<body>
<form id="form1" runat="server">
<div style="height: 3000px; background-color: Blue;">
</div>
</form>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>无标题页</title>
<script type="text/javascript" src="jquery-1.8.3.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$(window).scroll(function() {
//$(document).scrollTop() 获取垂直滚动的距离
//$(document).scrollLeft() 这是获取水平滚动条的距离
if ($(document).scrollTop() <= 0) {
alert("滚动条已经到达顶部为0");
}
if ($(document).scrollTop() >= $(document).height() - $(window).height()) {
alert("滚动条已经到达底部为" + $(document).scrollTop());
}
});
});
</script>
</head>
<body>
<form id="form1" runat="server">
<div style="height: 3000px; background-color: Blue;">
</div>
</form>
</body>
</html>