javascript 스크롤 바 스크롤 로드 내용 구현
6214 단어 JavaScript
단계 1: Visual Studio 2010 열기 ,새 항목 www. scrollpage. com.
STEP 2: HTML 파일 을 추가 합 니 다. 이름: ScrollLoadPage. html, 항목 은 Jquery 1.8.2 프레임 워 크 를 참조 합 니 다.
STEP 3: 코드 추가
<!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>
<title>demo</title>
<script src="jquery-1.8.2.min.js" type="text/javascript"></script>
<style type="text/css">
div#Loadding { text-align: center; margin-top: 10px; display: none; font-weight: bold; color:Red; }
div.content { width: 100%; height: 900px; border-bottom: 1px solid gray; font-weight: bold; color:Red;text-align: center;}
</style>
<script type="text/javascript">
if (!NeuF) var NeuF = {};
NeuF.ScrollPage = function (obj, options, callback) {
var _defaultOptions = { delay: 500, marginBottom: 100 }; // : delay marginBottom
options = $.extend(_defaultOptions, options);
this.isScrolling = false; //
this.oriPos = 0; //
this.curPos = 0; //
var me = this; //
var $obj = (typeof obj == "string") ? $("#" + obj) : $(obj);
//
$obj.scroll(function (ev) {
me.curPos = $obj.scrollTop();
if ($(window).height() + $(window).scrollTop() >= $(document.body).height() - options.marginBottom) {
if (me.isScrolling == true) return;
me.isScrolling = true;
setTimeout(function () { me.isScrolling = false; }, options.delay); //
if (typeof callback == "function") callback.call(null, me.curPos - me.oriPos);
};
me.oriPos = me.curPos;
});
};
$(function () {
window.scrollTo(0, 0); // F5
//marginBottom ,0 ,
new NeuF.ScrollPage(window, { delay: 1000, marginBottom: 0 }, function (offset) {
if (offset > 0) {
$("#Loadding").show(); //
setTimeout(function () {
// , ,
$("#divContainer").append($("<div class='content'> “" + ($(".content").size() + 1) + "” </div>"));
// ,
$("#Loadding").hide();
}, 1000);
}
});
});
</script>
</head>
<body>
<div id="divContainer">
<div class="content">
, , 。 ,<br /> CSS div.content , </div>
</div>
<div id="Loadding">
, ...</div>
</body>
</html>
STEP 4: 브 라 우 저 에서 scrollLoadPage. html 보기.
다음은 프로젝트 소스 코드 를 드 립 니 다. :
http://files.cnblogs.com/HCCZX/www.scrollpage.com.rar
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
기초 정리 - 1문자 (String) 숫자 (Number) 불린 (Boolean) null undefined 심볼 (Symbol) 큰정수 (BigInt) 따옴표로 묶어 있어야 함 Not-A-Number - 숫자 데이터 / 숫자로 표...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.