Simple Scripts to Password Protect Your Webpage
You always wanted to password protect your webpages. Some web pages are best kept private. The javascripts below are simple ways to protect using a password your webpage.
WARNING : As I said, these scripts are very simple javascript. They are the first line to protect privacy of webpages. Someone who can access the html page souce code can easily find the username and password and enter the page. The script will NOT work in Javascript disabled browsers or older browser versions not supporting javascript. So it is basically to stop routine surfers from accessing your pages. Anyone with a little idea about html and computers can see the source code. So if you have something IMPORTANT that you really want to password protect and not allow any access at all, DO NOT USE these and try alternative means.
Usage – Insert the code in between the HEAD tags of your webpage.
Password Protection Script 1
The javascript displays a form to enter the Username and Password. If either is wrong, it will display and alert screen like ‘Wrong Username’ or ‘Wrong Password’. The username is set to ‘secretname’ and the password is ‘secretpassword’ – both can be set as you like. If both are right, then you are taken to the next url, which is currently set to this blog.
<script language="javascript">
<!--// function pasuser(form) { if (form.id.value=="secretname") { if (form.pass.value=="secretpassword") { location="http://quickonlinetips.com/" } else { alert("Wrong Password") } } else { alert("Wrong Username") } } //-->
</script>
<form name="login">
Username: < input name="id" size="6" type="text">Password: < input name="pass" size="6" type="password">< input value="Login" onclick="pasuser(this.form)" type="button">
</form>
Password Protection Script 2
Insert this code in the ‘Head’ tags of the web page. When you enter the page, it will ask for a password, currently set to ‘secretpassword’. If the password is correct, you will be allowed to enter the page. Otherwise you can set it to redirect to any other page, currently it is set to this blog.
<SCRIPT language="JavaScript">
<!-- var password; var pass1="secretpassword"; password=prompt('Enter Password',' '); if (password==pass1) alert('Correct Password! Click OK to Enter!'); else { window.location="http://quickonlinetips.com/"; } //-->
</SCRIPT>
Insert these scripts into your html code for simple password protection of your pages. But remember the warning as mentioned before.













Any idea why I can’t get any of those scripts to work on my blog??? Could it be blogger blocking it? Please help!!! THANK YOU!
I just see the scripts (Both) printed in my blog instead of implemented. Why doesn’t it work?
u have to remove the comments….so u remove the 2nd and the 2nd last line
I did what you said and it still doesn’t work
works for me. nice post. simple, and stops the average person. i used the 2nd script.
thanks — mark