Recently, I've been working on a project to implement a feature that automatically closes the website when an incorrect password is entered. However, I am fairly new to JavaScript and still in the early stages of learning.
Below is the code snippet I have been experimenting with:
<!DOCTYPE html>
<html id="web" lang="en">
<head>
<meta charset="UTF-8>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>MySite</title>
<script>
var web = document.getElementById("web");
var password = "BigDips12";
alert("Hey, For security messures and to make sure you");
var security = prompt("Please enter the password here:");
if (security === password) {
alert('Welcome!')
} else {
alert('Password is wrong! The program will close itself now..')
function closeWin() {
web.close();
}
}
</script>
</head>
<body>
<h1>Hello World!</h1>
</body>
</html>
I could really use some guidance on this. Please help!