'Program Study/Tip & Tech'에 해당되는 글 3건

  1. 2011.08.25 Jquery를 사용한 비동기화 구현
  2. 2010.12.19 스크롤이 마지막인지 체크하기
  3. 2010.11.18 플래시와 동적 xml생성시 캐쉬에 안남기는 법(JSP의 경우)
2011. 8. 25. 11:59

Jquery를 사용한 비동기화 구현

function xDomainProc(puzlNum){
    var tmp_ifr = $('<iframe />')
       .attr({'name':'temporary_ifr','id':'temp_ifr'})
        .hide()
       .load(function() {
                   $('#temporary_frm').remove();
                   var resetFlag = $('#temp_ifr').contents().find('#resetFlag').html();
                   var firstAccess = $('#temp_ifr').contents().find('#firstAccess').html();
                   var success = $('#temp_ifr').contents().find('#success').html();

if(success){
                    $('.iconpopup2').hide();
                    $('.puzzleeventPopup2 p:eq(0)').text('<%=iPuzlCnt+1%>')
                    $('.puzzleeventPopup2').show();
/*
                    if(firstAccess == "true"){
                    $('.puzzleeventPopup2').hide();
                    $('.puzzleeventPopup1').show();
                    }else if(resetFlag == "true"){
                    $('.puzzleeventPopup3 p:eq(0)').text('<%=iComplPuzl+1%>')
                    $('.puzzleeventPopup2').hide();
                    $('.puzzleeventPopup3').show();
                    }
*/ 
                   }else{
                    alert('fail');
                   }
                   //$(this).remove();
               });
var tmp_frm = $('<form />')
       .attr({'id':'temporary_frm',
               'action':'url',
               'method':'post',
               'target':'temporary_ifr'})
       .append($('<tag/>'))

$('body').append(tmp_ifr).append(tmp_frm);
//$('body').append(tmp_frm);
//tmp_frm.submit();
    }
2010. 12. 19. 23:01

스크롤이 마지막인지 체크하기

 function scrollAutoTestFnc(){
     //현재문서의 높이
     var scrollHeight = Math.max(document.documentElement.scrollHeight, document.body.scrollHeight);

    //현재 스크롤탑의 값
    var scrollTop = Math.max(document.documentElement.scrollTop, document.body.scrollTop);

    //현재 화면 높이 값
    var clientHeight = document.documentElement.clientHeight;

    if((scrollTop+clientHeight) == scrollHeight){ //스크롤이 마지막일때
      alert("last") ;
    }
 }
 window.onscroll=function(){
    scrollAutoTestFnc();
 }
자 이건 어디에 써먹을 수 있느냐.
요즘 스마트폰에서 스크롤을 내리다보면 내용이 계속 추가 되는게 보일텐데;;
상탄의 alert부분에 AJAX로 작동하는 Contents 내용 추가 해주는 함수를 넣어주면 스크롤이 젤 하단에 내려가면 
자동으로 일정부분  Contents가 추가 되는 화면 구성을 만들 수 있을 것이다.

아직 실험은 안해봤지만;;;
요즘 만들고 있는 Android Hybrid Application에 적용해 보려합니다.

Chrome 브라우져에서도 되야 하는데;;;
내일 확인해 봐야겠음돠.ㅋ 기대기대~~+_+

다른 브라우져의 Object확인은
2010. 11. 18. 18:51

플래시와 동적 xml생성시 캐쉬에 안남기는 법(JSP의 경우)

<%
//xml생성시 캐쉬에 남지 않게하기
String httpVersion = request.getProtocol();
if(httpVersion.equals("HTTP/1.0")){
response.setDateHeader("Expires",0);
response.setHeader("Pragma", "no-cache");
}else if(httpVersion.equals("HTTP/1.1")){
response.setHeader("Cache-Control", "no-cache");
}
%>

JSP로 동적 xml구현시 캐쉬에 남기지 않아야 동적으로 처리가 된다.