2016-06-15 2 views
-3

자바 스크립트와 if 루프를 사용하여 비밀번호를 확인합니다. 그러나 자바 스크립트가 아닌 문자열을 입력하면 경고가 표시되지 않습니다. 여기 내 코드가있다.자바 스크립트 비밀번호 검사기

<script type = "text/javascript"> 
function password_prompt() { 

    var password = window.prompt("Please enter the correct password ", ""); //password = javascript 
    if (password == "javascript") { 
    var x = window.confirm("Please confirm you want to enter the webpage!"); 
     if (x != 1) { 
     window.close(); 
     window.open("https://www.google.com/"); 
    } 
    if (password != "javascript") { 
     window.alert("You entered the wrong password! Page will now close!"); 
    window.close(); 
    window.open("about:blank"); 
     } 

    } 
} 
</script> 
+8

들여 쓰기 코드 당신이 볼 수 – BeyelerStudios

+2

OT : 자바 스크립트위한 인증 나쁜 생각이 ... :) –

+2

금지 된 암호가 나쁜 생각 –

답변

-1

<script type = "text/javascript"> 
 
function password_prompt() { 
 

 
    var password = prompt("Please enter the correct password ", ""); //password = javascript 
 
    if (password == "javascript") { 
 
    var x = confirm("Please confirm you want to enter the webpage!"); 
 
     if (x != 1) { 
 
     window.close(); 
 
     window.open("https://www.google.com/"); 
 
    } 
 
    if (password != "javascript") { 
 
     alert("You entered the wrong password! Page will now close!"); 
 
    window.close(); 
 
    window.open("about:blank"); 
 
     } 
 

 
    } 
 
} 
 
</script>

+0

http://www.w3schools.com/jsref/met_win_prompt.asp 문서 –

+0

을 입력하면 볼 수 있습니다. 자바 스크립트와 다른 뭔가 경고가 표시되지 않습니다. –

+0

비밀번호 값이 "javascript"와 같지 않으면 console.log (비밀번호)는 비밀번호 현재 값 –

-1
<script type = "text/javascript"> 
function password_prompt() { 

    var password = window.prompt("Please enter the correct password ", ""); //password = javascript 
    if (password == "javascript") { 
     var x = window.confirm("Please confirm you want to enter the webpage!"); 
     if (x != 1) { 
      window.close(); 
      window.open("https://www.google.com/"); 
     } 
    } 
    if (password != "javascript") { 
     window.alert("You entered the wrong password! Page will now close!"); 
     window.close(); 
     window.open("about:blank"); 
    } 
} 
</script> 
관련 문제