This article example describes the method of obtaining the return value of the session box prompt. Share it for your reference. The specific analysis is as follows:
To get the return value of the session box prompt, see example:
Copy the codeThe code is as follows:
<html>
<head>
<script type="text/javascript">
if(prompt("Please enter password","") == "admin"){
("The password is correct");
}else{
("Password Error");
}
</script>
</head>
</html>
<head>
<script type="text/javascript">
if(prompt("Please enter password","") == "admin"){
("The password is correct");
}else{
("Password Error");
}
</script>
</head>
</html>
Notice:
prompt returns the data type as a string.
alert(): No return value;
confirm(): Returns true or false
I hope this article will be helpful to everyone's JavaScript programming.