공부/컴퓨터
[HTTP] 자바 스크립트 사용 페이지 보여주기
찬
2003. 7. 14. 12:08
반응형
페이지 이동
pageList (target, start, scale, view, total, URL)
target = 표시할 객체
start = 글위치 (페이지 단위가 아니고 순차적인 글의 위치)
scale = 페이지의 글리스트 갯수
view = 표시될 페이지 갯수
total = 전체 글 갯수
URL = 링크URL (마지막에 '&'은 빼고... 안빼도 상관없지만^^)
<TABLE bgColor=#999999 height=30><TR><TD><DIV id=pageListDIV></DIV></TD></TR></TABLE>
<SCRIPT>
function pageList (target, start, scale, view, total, URL) {
var html = "";
var reLoading = " <a href=\"javascript:pageList(" +target.id+ ",{page}," +scale+ "," +view+ "," +total+ ",'" +URL+ "');\">{PAGE}</a>";
if (total % scale) add = 1; else add = 0;
maxPage = Math.floor(total / scale) + add;
begin = Math.floor(Math.floor(start/(scale * view)) * view + 1);
end = Math.floor(begin + view - 1);
if(end > maxPage) end = maxPage;
if (begin > 1) {
html += " <a href='" +URL+ "&start=0'>[1]</a>";
html += reLoading.replace ("{page}", (begin-2)*scale).replace ("{PAGE}", "◀:");
}
for(var i=begin; i<=end; i++) {
page = (i - 1) * scale;
if(start != page) {
html += " <a href='" +URL+ "&start=" +page+ "'>[" +i+ "]</a>";
} else {
html += " <b>" +i+ "</b>";
}
}
if (end < maxPage) {
if (end < maxPage-1) {
html += reLoading.replace ("{page}", end*scale).replace ("{PAGE}", ":▶");
}
page = maxPage * scale;
html += " <a href='" +URL+ "&start=" +page+ "'>[" +maxPage+ "]</a>";
}
target.innerHTML = html;
}
pageList (self.pageListDIV, 0, 30, 10, 2000, 'http://phpschool.com/bbs2/inc_board.html?mode=&field=&period=&s_que=&code=tnt2&operator=&category_id=');
</SCRIPT>
pageList (target, start, scale, view, total, URL)
target = 표시할 객체
start = 글위치 (페이지 단위가 아니고 순차적인 글의 위치)
scale = 페이지의 글리스트 갯수
view = 표시될 페이지 갯수
total = 전체 글 갯수
URL = 링크URL (마지막에 '&'은 빼고... 안빼도 상관없지만^^)
<TABLE bgColor=#999999 height=30><TR><TD><DIV id=pageListDIV></DIV></TD></TR></TABLE>
<SCRIPT>
function pageList (target, start, scale, view, total, URL) {
var html = "";
var reLoading = " <a href=\"javascript:pageList(" +target.id+ ",{page}," +scale+ "," +view+ "," +total+ ",'" +URL+ "');\">{PAGE}</a>";
if (total % scale) add = 1; else add = 0;
maxPage = Math.floor(total / scale) + add;
begin = Math.floor(Math.floor(start/(scale * view)) * view + 1);
end = Math.floor(begin + view - 1);
if(end > maxPage) end = maxPage;
if (begin > 1) {
html += " <a href='" +URL+ "&start=0'>[1]</a>";
html += reLoading.replace ("{page}", (begin-2)*scale).replace ("{PAGE}", "◀:");
}
for(var i=begin; i<=end; i++) {
page = (i - 1) * scale;
if(start != page) {
html += " <a href='" +URL+ "&start=" +page+ "'>[" +i+ "]</a>";
} else {
html += " <b>" +i+ "</b>";
}
}
if (end < maxPage) {
if (end < maxPage-1) {
html += reLoading.replace ("{page}", end*scale).replace ("{PAGE}", ":▶");
}
page = maxPage * scale;
html += " <a href='" +URL+ "&start=" +page+ "'>[" +maxPage+ "]</a>";
}
target.innerHTML = html;
}
pageList (self.pageListDIV, 0, 30, 10, 2000, 'http://phpschool.com/bbs2/inc_board.html?mode=&field=&period=&s_que=&code=tnt2&operator=&category_id=');
</SCRIPT>
반응형