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.
« Previous Post Next Post »



I’ve been thinking… (I don’t know the Java language) how about using some one-way coding algorithm, so it could be more secure (the page storing the encoded form of the pw). something like this
Works for me too. Thanks for the script. I have one question though. I noticed that the password prompt only appears when I type my Blogspot address exactly as it’s shown to me when I log in and go under Settings and then Publishing (ie. without the ‘World Wide Web’ part of the address). Is there a way to get the prompt to show up even with different variations of my address? By typing in my address starting with ‘www’, people can still access my blog without the password. Thanks in advance. I’m not very computer savvy. Any help would be appreciated.
I just have a basic blogger blog – do I enter the codes into the ‘Template’ section? If so, where in the Template html do I enter it? I’ve tried to enter it into the ‘head’ section and the password isn’t coming up…
Thanks for your help!
Hi;
I’m really keen to use these scripts, I’ve tried both html codes but I can’t seem to get the passwords to work. I would be really grateful. I’m mostly just getting the text appear at the top of my blog. Thanks heaps – awesome website!
Please see that the all code inbetween the script tags of the code is inserted between the HEAD tags of your page. Maybe that is why the text is showing on your blog.