1. Go to Blogger > Template > Edit HTML

2. Now press Ctrl + F and search for the </body> tag and add below code above it.

<script>
var password = ‘Password-Here
password=prompt(‘Please enter the password to enter this site:’,”);
if (password != ‘Password-Here‘) {
location.href=’Redirect-URL-Here‘}
</script>

3. Now just press Save Template and refresh your blog to see the password asking popup.

Customizations :

You can change the password according to your wish, however, just change the letters in red color to your password. You can add any URL to which the visitor will be redirected if (s)he enters the wrong password or cancel to add any password, just change the Blue line in the above code with your URL.

 

Createa New Page on your Main Blog.

    • If you are password protecting Blog B which is a family blog for example, then in your main blog, Blog A, you may wish to create a "page" thats entiled "Password Needed" and in that page you write a simple note explaining that "The blog you were trying to view is password protected. If you feel you are reaching this message in error, please contact me at <your email address>."
    • Publish the page (no gadget to be added).
    • View Page to get the URL.
  • Save/Note this URL as you need it in the following steps.

Put into action!

Next, login to Blogger, go to the Dashboard and click Design.  If using the new Blogger interface, then go to your blog and click on Layout (from the left).

Next, click Add a Gadget and choose HTML/JavaScript.

Copy and paste in this code (also downloadable here) in the large text box (leaving the title blank):

Edit this code.

  • Change the occurances of the word TypePad with whatever password you want to use.
  • Replace the URL of http://www.BlogsByHeather.com with the URL from the page you previously created above in the prep work area.

In the HTML/JavaScript gadget, click Save to save the code.


<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
var password = 'TypePad'
password=prompt('Please enter the password to enter this site:','');
if (password != 'TypePad') {
location.href='http://www.BlogsByHeather.com';
}
// End -->
</SCRIPT>
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
var password = 'TypePad'
password=prompt('Please enter the password to enter this site:','');
if (password != 'TypePad') {
location.href='http://www.BlogsByHeather.com';
}
// End -->
</SCRIPT>