2
이 원본은 나의 일원 컴퓨터에 많은 자원을 먹고있다. 나는 어떤 리소스도 먹지 않는 다른 인터벌 스크립트를 가지고있다. 나는 시간을 연장하려고 노력했지만 새로 고침이 늦어진다. 어떤 제안?큰 자원 먹는 사람
<script type="text/javascript">
$('document').ready(function(){
updatestatus();
scrollalert();
});
function updatestatus(){
//Show number of loaded items
var totalItems=$('#scontent p').length;
$('#status').text('Done');
}
function scrollalert(){
var scrolltop=$('#scrollbox').attr('scrollTop');
var scrollheight=$('#scrollbox').attr('scrollHeight');
var windowheight=$('#scrollbox').attr('clientHeight');
var scrolloffset=10;
if(scrolltop>=(scrollheight-(windowheight+scrolloffset)))
{
//fetch new items
$('#status').text('Loading more members...');
$.get('allonline.php', '', function(newitems){
$('#scontent').load('allonline.php');
updatestatus();
});
}
setTimeout('scrollalert();', 60000);
}
</script>
아마도 이것이 주요 문제 일 것입니다. 다른 것들 : 같은 요소에 대해 '$ (# foo')를 반복해서 호출하는 대신 어딘가에 캐시하십시오. 또한,'setTimeout' 호출은'setTimeout (scrollAlert, 6000);이어야합니다. – Pointy