자동 스크롤 모바일 웹이 모바일 크롬에서만 작동되지 않습니다.
본문
<?php
if (!defined('_GNUBOARD_')) exit; // 개별 페이지 접근 불가
?>
<style>
.m_more01{width:100%;overflow:hidden;text-align:center;background-color:#f0f2f3;padding:7px 0;margin:10px 0;border:1px solid #d4d4d4;font-weight:bold;color:#8c8c8c;font-size:13px;}
</style>
<script>
(function($) {
$(function() {
addList(1);
$(window).scroll(function() {
if ($(window).scrollTop() == $(document).height() - $(window).height())
{
var ID = $(".morebox>span").attr("id");
addList(ID);
}
});
});
})(jQuery);
function addList(no){
if(no){
$("#more"+no).html('<img src="<?=$board_skin_url?>/img/moreajax.gif" />');
$.ajax({
type: "POST",
url: "<?=$board_skin_url?>/list.more.php",
data: "bo_table=<?=$bo_table?>&pg="+ no + "&sop=<?=$sop?>&stx=<?=$stx?>&sca=<?=$sca?>&sfl=<?=$sfl?>",
cache: false,
success: function(html){ //alert( html );
if(html.indexOf("td_subject") == -1){
$(".morebox").html('마지막페이지입니다');
}else{
$("#updates").append(html);
$("#more"+ no).remove();
}
}
});
}
else{
$(".morebox").html('마지막페이지입니다');
}
return false;
}
</script>
<!-- 게시판 목록 시작 -->
<form name="fboardlist" id="fboardlist" action="./board_list_update.php" onsubmit="return fboardlist_submit(this);" method="post">
<input type="hidden" name="bo_table" value="<?php echo $bo_table ?>">
<input type="hidden" name="sfl" value="<?php echo $sfl ?>">
<input type="hidden" name="stx" value="<?php echo $stx ?>">
<input type="hidden" name="spt" value="<?php echo $spt ?>">
<input type="hidden" name="page" value="<?php echo $page ?>">
<input type="hidden" name="sw" value="">
<div id="updates" style="float:left;"></div>
<div class="m_more01 morebox" id="more1" onclick="addList(1)"><span name=mc id="1">MORE ▼</span></div>
</form>
<!-- 게시판 목록 끝 -->
위 소스입니다.. 자바스크립트쪽에 문제가 있는건지 PC에서는 익스나 크롬 모두 잘되고, 안드로이드에서도 잘되는데 안드로이드 크롬브라우저에서만 more를 클릭하지않는 한 자동으로 스크롤이 되지 않습니다. 때로는 첫 페이지만 될때도 있구요..
if ($(window).scrollTop() == $(document).height() - $(window).height()) 이게 문제인거같기도 한데.. ==를 <=로 바꾸면뒤에 모든 페이지를 읽어오는걸로 봐서 나머지 스크립트는 모두 정상인거같습니다.
안드로이드 기본 브라우저로는 잘 되는데 크롬에서만 버튼 안누르면 다음 페이지 내용 append가 안되니 골머리가 아프네요 ㅜㅜ
!-->답변 1
pc와 모바일은 환경이 다르기 때문에 pc에서 적용되던 스크립트가 모바일에는 작동이 되지 않을 수 있습니다.
scrollTop() 함수 대신 scrollTo(x,y)로 대체해서 적용해보세요.
답변을 작성하시기 전에 로그인 해주세요.