⟩ How do I use JavaScript to password-protect my Web site?
There are several ways in which you can use JavaScript to password-protect your website. This can be done by setting the password by using the given name or pathname of HTML file on your site. Set the location to value entered in the field. Entry of wrong password will result in "invalid URL" error. If password protect pages requires more security then you can set temporary cookies on the page.