Password protect pages using javascript
Hello guys here is a simple code on how to password protect a webpage usingĀ javascript.This is not a good idea coz it is not at all secure.But simply just like that a webpage which is protected using simple javascript is fun.
<script type=“text/javascript”>
function passWord() {
var testV = 1;
var pass1 = prompt(’Please Enter Your Password’,’ ‘);
while (testV < 3) {
if (!pass1)
history.go(-1);
if (pass1.toLowerCase() == “iamlost”) {
alert(’You Got it Right!’);
window.open(’theotherpage.html’);
break;
}
testV+=1;
var pass1 =
prompt(’Access Denied - Password Incorrect, Please Try Again.’,'Give Me The Password’);
}
if (pass1.toLowerCase()!=”password” & testV ==3)
history.go(-1);
return ” “;
}
</SCRIPT>
<CENTER>
<FORM>
<input type=”button” value=”Enter Protected Area” onClick=”passWord()”>
</FORM>
</CENTER>
In the next version of this tutorial i can tell you guys how we can hide a div element and get the password from it do visit me often guys.
Related posts:
- Get browser version and details using javascript
- Check password strength using javascript
- DOM elements dynamically using our JAVASCRIPT
- Words Validation with Javascript
- WordPress Vulnerability
- Pass PHP Value To Javascript
- Simple message slideshow news ticker using javascript
