-- ex1

window.onpageshow = function() {
        if ( event.persisted || (window.performance && window.performance.navigation.type == 2) ) {
        }
}

 

-- ex2

//뒤로가기 체크.

$(window).bind("pageshow", function(){        
            /**

             * 아이폰 사파리에서 사용.
             * 뒤로가기로 진입시 수행.
             */
            if ( event.persisted ) {

 

                 //server 호출 시 async : false ( 동기 ) 방식으로 호출해야 함. 동기방식으로 하징낳으면 아이폰 사파리에서 서버 호출을 하지않음.

             }

}

//아이폰 사파리 제외 사용.

if ( cfn_performanceCheck( 'back_forward' ) ) {

}

 

// 퍼포먼스 체크
function cfn_performanceCheck(type){
    console.log(performance.getEntriesByType("navigation"));
    var rtnValidator = false;
    if(performance.getEntriesByType("navigation").length > 0){
        if(performance.getEntriesByType("navigation")[0].type == type){
            rtnValidator = true;
        }
    }
   
    return rtnValidator;
}

 

 

+ Recent posts