Javascript

Javacript - 웹페이지에서 뒤로가기 방지

개발 그리고 게발 2021. 8. 13. 18:00
728x90

웹페이지에서 뒤로가기를 방지하려고 하는 경우 Script에 다음과 같은 소스를 작성해서 추가해보도록 하자!

 

history.pushState(null, null, location.href);
window.onpopstate = function (event) {
	history.forward();
};
728x90