기능 설명 : 웹 사이트의 웹 페이지를 열고 5 분 후에 이동하지 않으면 페이지가 잠겨 있고 컨텐츠 컨테이너가 숨겨지고 암호를 입력하기 위해 컨테이너가 표시됩니다. 올바른 비밀번호를 입력하여 잠금을 해제하십시오. 잠금 후, 사용자가 페이지를 새로 고치더라도 원래 상태는 유지됩니다. 잠긴 경우 계속 잠금해야합니다. 그렇지 않으면 내용이 표시됩니다.
샘플 코드는 다음과 같습니다. document.onmouseover를 사용하여 몇 분 동안 조치를 취하지 않고 타이머를 사용하여 구현하십시오.
<! doctype html public "-// w3c // dtd xhtml 1.0 transitional // en" "http://www.w.w.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"><Html xmlns = "http://www.w3.org/1999/xhtml"> <head> <meta http-equiv = "content-type"content = "text/html; charset = utf-8"/> <title> JavaScript는 시스템 화면 보호 효과 (잠금 웹 페이지) </head> <dy div> id = "dvcontent"> content <br /> content <br /> content <br /> content <br /> content <br /> content <br /> content <br /> content <br /> content < /div> <div id = "dvpassword"style = "display : none"> Enter 비밀번호 : <입력 유형 = <입력 유형 = "txtpwd" /> <입력 유형 = "value ="volic = "valk" "valk" "valk" (Document.cookie.indexof ( 'lock = 1')! = -1) showcontent (false); var Delay = 10 * 1000, 타이머; // 10 초 이후에 잠금, 밀리 초 함수 startTimer () {cleartimeout (타이머); 타이머 = settimeout (TimerHandler, Delay); } function timerHandler () {document.Cookie = 'lock = 1'; document.onmouseMove = null; // ShowContent 잠금 후 마우스 이동 이벤트 제거 (false); } 함수 showContent (show) {document.getElementById ( 'dvcontent'). style.display = show? '블록': '없음'; document.getElementById ( 'dvpassword'). style.display = show? '없음': '블록'; } function check () {if (document.getElementByid ( 'txtpwd'). value == '123') {document.cookie = 'lock = 0'; Showcontent (True); STARTTIMER () // retime document.onmouseMove = startTimer; // rebind mouse movement event} else alert ( '비밀번호가 잘못되었습니다!!'); } window.onload = function () {document.onmouseMove = startTimer; STARTTIMER (); } </script> </body> </html>