Javascript is not proper or prefect solution. It can be disabled and any passwords would need to be stored in the actual html page where anyone can see it. You need to use a server side language. You can use a server-side scripting language like PHP or ASP.
If you are hosting on Linux/Apache, an easy & effective way to do this is using the .htaccess file . Or is you are want simple password protection then get the following code:
Code:
<!-- ONE STEP TO INSTALL PASSWORD PROMPT:
1. Put the designated coding into the BODY of your login HTML document -->
<!-- STEP ONE: Copy this code into the BODY of your login HTML document -->
<BODY>
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
var password = ''
password=prompt('Please enter your password:','');
if (password != null) {
location.href= password + ".html";
}
// End -->
</SCRIPT>
Bookmarks