$(document).ready(function() {
$(document).display(none);
var password =("You have just entered a private website. Please enter the password to access it!");
if (password == "biology") {
$(document).display();
}
else {
window.location.replace("https://www.google.co.uk")
};
});
html {
background-image: url("bg.jpg")
}
body {
margin: 0 25%;
background-color: #ccc;
}
nav li {
padding-left: 5px;
border: solid 5px #aaa;
}
nav ul {
list-style-type: none;
position: fixed;
left: 9%;
font-size: 36px;
}
nav a {
color: #ccc;
text-decoration: none;
}
article {
background-color: white;
border: white solid #c0c;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<!DOCTYPE html>
<html lang="pl">
<head>
<title>Krystian Mikołajczyk</title>
<link href="style.css" rel="stylesheet" type="text/css">
<link href="jquery-2.1.1.js" type="text/javascript">
<link href="pass.js" type="text/javascript">
</head>
<body>
<header>
<h1 align="center"><i>Krystian Mikołajczyk</i></h1>
</header>
<nav>
<ul><i>
<li><a href="#">Home</a></li>
<li><a href="#">Uploads</a></li>
<li><a href="#">Downloads</a></li>
<li><a href="#">Contact</a></li>
</i></ul>
</nav>
<br>
<br>
<br>
<article>
<section>
<h1>Recent Update</h1>
</section>
</article>
</body>
</html>
I was trying to make a website for myself that I can use anywhere any time and I wanted to protect it with a password, especially if I was going to have some downloads and uploads that I wanted to keep for myself.
The password is suppose to be "biology" because I would like my biology teacher to upload a pdf book for me during the development.
I don't know what I did wrong but the prompt message didn't want to come up and that's what I'm wondering about.
tl;dr
You got some errors in your code. Go to straight to working demo.
.display(none) is invalid
This is invalid since none is not a defined variable, either remove it or use an alternative:
or
You need to prompt the user
This will not do anything, but you can use the prompt method to ask for an input:
If-else statements should not contain semicolons (;)
should simply be:
There might be more!
Check your developer tools to be certain. They're awesome!
Note
... that you're no way near being safe since your password is stored as plain text and easily found by viewing the source of the client. There's a lot of material on how to hash password properly, store them and compare them with a hashed input value of the user -- but that's another story.