개발자의 길

[자바스크립트] 뒤로 가기 버튼 아예 막기 본문

2. JS

[자바스크립트] 뒤로 가기 버튼 아예 막기

자르르 2011. 5. 13. 13:40



이게 좋은 방법인지는 모르겠다..

차라리 중간에 페이지 하나 더 둬서 location.replace=""; 이걸로 가는게 더 확실하지 않을까?

여의치 않으면 이 방법을 쓰길

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<title>Untitled Page</title>
<script type = "text/javascript" >
function changeHashOnLoad() {
     window.location.href +=
"#";
     setTimeout(
"changeHashAgain()", "50");
}

function changeHashAgain() {
  window.location.href +=
"1";
}

var storedHash = window.location.hash;
window.setInterval(
function () {
   
if (window.location.hash != storedHash) {
         window.location.hash = storedHash;
    }
},
50);


</script>
</head>
<body onload="changeHashOnLoad(); ">
Try to hit the back button!
</body>
</html>



이 포스팅은 쿠팡 파트너스 활동의 일환으로, 이에 따른 일정액의 수수료를 제공받습니다.
공유하기 링크
Comments