[JavaScript] 뒤로가기 캐치

//history.pushState 사용으로 URL 이동 후 뒤로가기 캐치.
window.onpopstate = function(event) { //console.log(event.state);
  if(typeof call_list === "function"){
      call_list();
  }
};
// Back Forward Cache로 브라우저가 로딩될 경우 혹은 브라우저 뒤로가기 했을 경우
window.onpageshow = function(event) {
  if ( event.persisted || (window.performance && window.performance.navigation.type == 2)) { console.log(event);
    if(typeof call_list === "function"){
        call_list();
    }
  }
};
guest
0 Comments
Inline Feedbacks
View all comments