Password protect HTML file

This is another script that was used due to a requirement that came about, and that requirement was to password protect a HTML file using JavaScript

The point would be, you would go to the website where you need to serve restricted content, but I restricted content I mean, you couldn't get to it without knowing the password

This little script gets put at the top of your HTML before your website contents, the thing I like about the script is you cannot see the contents of the script until you know the password, yes, the password is not encrypted, but you can't see the password unless you know it because the HTML page does not load.

It's not security protection and it's definitely not a web application firewall or WAF, but it's a simple script to fill a requirement.

<script language="JavaScript">
<!-- Begin
var password = 'password'
password=prompt('Password Protected entry, please enter the password:','');
if (password != 'mypasword') {
location.href='http://www.google.com';
}
// End -->

If you insert the code into HTML document When you load the document, it will prompt you for the password as per the password=prompt message 

If you enter the password, specified as "mypassword" the site will then continue to load, if you into anything else or click the cancel button you will end up on Google

WARNING : This does not securely protect you from anything, back in the 1990 to this would’ve probably been considered challenging, but in today’s modern world, this is simply a deterrent, it will keep the majority of uninitiated people out for sure.

Previous Post Next Post

Ω†Ω…ΩˆΨ°Ψ¬ Ψ§Ω„Ψ§ΨͺΨ΅Ψ§Ω„