Javascript: Password Tips
If you want a page to be password protected, look at these html tips and tricks.
The first step is to find a web page that is password protected.
Mine is: http://htmlpassprotect.blogspot.com/
The second step is to find a web page that will be gone to if the visitor types in the wrong password.
I chose: http://htmltips.blogspot.com/
It may be better, however, to make a page that will say, for example, "YOUR PASSWORD IS INCORRECT. CLICK HERE TO TRY AGAIN. CLICK HERE TO GO BACK."
The third step is to insert the following code in between <head> and </head> on your password protected page:
<SCRIPT language="JavaScript">
<!--hide
var password;
var pass1="cool";
password=prompt('Please enter your password to view this page!',' ');
if (password==pass1)
alert('Password Correct! Click OK to enter!');
else
{
window.location="http://htmltips.blogspot.com";
}
//-->
</SCRIPT>
The four messages in italics show:
-The password
-The prompt that asks the visitor to type in the password
-The message that is displayed if a user types in the password correctly
-The address that the visitor goes to if they typed in the wrong password (This should probably be the site that you made in the second step)
Those four messages may be changed if you desire.
To make a link to the password protected page, simply use the <a> tag:
<a href="http://addressofthesitethatispasswordprotected.com>Click here to go to the password protected site</a>
That is what I have done here:
Click here to go to the password protected site
Note: Cool is the password for my password protected site.
Finally, to make multiple passwords possible, you will have to look at the original javascript which is on the password protected page:
<SCRIPT language="JavaScript">
<!--hide
var password;
var pass1="cool";
password=prompt('Please enter your password to view this page!',' ');
if (password==pass1)
alert('Password Correct! Click OK to enter!');
else
{
window.location="http://htmltips.blogspot.com";
}
//-->
</SCRIPT>
First, you will need to look at first text in italics.
var pass1="cool";
Change this to:
var pass1="cool";
var pass2="cool2";
var pass3="cool3";
...And then new passwords will be declared.
Make sure you change cool, cool2, and cool3 for your own passwords.
Finally, you need to look at the second text in italics:
password==pass1
That will need to be changed to, in this case:
password==pass1||pass2||pass3
That javascript literally says:
"if the password that the user entered is the same as password 1 or password 2 or password 3, then follow the instructions below"
If you were to make these changes to the password page, then the password page would accept cool2 and cool3 as a password also, in addition to cool.
To add more than 3 passwords, just add more of these:
var pass4="password"
...and make sure to change pass4 to another name each time you add it again to the code.
Adn edit the:
password==pass1
To include all your password names. (Seperate the password names by ||) (The password name in var pas10="cool10" is pas10)
The first step is to find a web page that is password protected.
Mine is: http://htmlpassprotect.blogspot.com/
The second step is to find a web page that will be gone to if the visitor types in the wrong password.
I chose: http://htmltips.blogspot.com/
It may be better, however, to make a page that will say, for example, "YOUR PASSWORD IS INCORRECT. CLICK HERE TO TRY AGAIN. CLICK HERE TO GO BACK."
The third step is to insert the following code in between <head> and </head> on your password protected page:
<SCRIPT language="JavaScript">
<!--hide
var password;
var pass1="cool";
password=prompt('Please enter your password to view this page!',' ');
if (password==pass1)
alert('Password Correct! Click OK to enter!');
else
{
window.location="http://htmltips.blogspot.com";
}
//-->
</SCRIPT>
The four messages in italics show:
-The password
-The prompt that asks the visitor to type in the password
-The message that is displayed if a user types in the password correctly
-The address that the visitor goes to if they typed in the wrong password (This should probably be the site that you made in the second step)
Those four messages may be changed if you desire.
To make a link to the password protected page, simply use the <a> tag:
<a href="http://addressofthesitethatispasswordprotected.com>Click here to go to the password protected site</a>
That is what I have done here:
Click here to go to the password protected site
Note: Cool is the password for my password protected site.
Finally, to make multiple passwords possible, you will have to look at the original javascript which is on the password protected page:
<SCRIPT language="JavaScript">
<!--hide
var password;
var pass1="cool";
password=prompt('Please enter your password to view this page!',' ');
if (password==pass1)
alert('Password Correct! Click OK to enter!');
else
{
window.location="http://htmltips.blogspot.com";
}
//-->
</SCRIPT>
First, you will need to look at first text in italics.
var pass1="cool";
Change this to:
var pass1="cool";
var pass2="cool2";
var pass3="cool3";
...And then new passwords will be declared.
Make sure you change cool, cool2, and cool3 for your own passwords.
Finally, you need to look at the second text in italics:
password==pass1
That will need to be changed to, in this case:
password==pass1||pass2||pass3
That javascript literally says:
"if the password that the user entered is the same as password 1 or password 2 or password 3, then follow the instructions below"
If you were to make these changes to the password page, then the password page would accept cool2 and cool3 as a password also, in addition to cool.
To add more than 3 passwords, just add more of these:
var pass4="password"
...and make sure to change pass4 to another name each time you add it again to the code.
Adn edit the:
password==pass1
To include all your password names. (Seperate the password names by ||) (The password name in var pas10="cool10" is pas10)
43 Comments:
Wow, that's a really useful tip. Thanks a lot!
By Anonymous, at May 13, 2005
Thanks for reading it...
By nilsmo, at May 13, 2005
never password protect something using javascript. This sucks.
By Anonymous, at September 25, 2005
Yes, javascript doesn't fully protect pages.
By nilsmo, at September 25, 2005
It's useful.. thanks for sharing. at least it'll stop ppl who are less skilful in html from looking.
By Anonymous, at February 01, 2006
thnx 4 ur tips!reali help alot!!!!!
By Anonymous, at February 01, 2006
JS is not completely secure, but it's good for, say, securing a family pictures site that only relatives can see or something. Obviously you don't want to protect, say, a banking site or something with it though.
By GL, at February 04, 2006
how came i couldn't get into your example page using the password 'Cool' ?
By Anonymous, at March 04, 2006
The password is 'cool' (without the single quotation marks), not 'Cool'.
By nilsmo, at March 04, 2006
Is there a way to make like a , website account like on YouTube? Or even an email account?
By Joshy, at January 19, 2009
Can you make like a website account?
Like a youtube account or a Google account?
By Anonymous, at January 19, 2009
Can you make like a website account?
Like You Tube or Google? that you can sign into?
By Joshy, at January 19, 2009
I can't get this to work. I paste the script, as is, right after the "head" tag. Nothing happens. I try moving the "/head" tag so that there's nothing but the script between them. Still nothing. I took a look at your example site, and I've got exactly the same text, although of course my bloggger template contains a lot more code than yours. What could I be doing wrong?
By Anonymous, at July 03, 2009
Hi there. tried the PW method for blog page but nothing seem to work. where did i go wrong?
By Anonymous, at July 16, 2009
Company was peered my jewelry replica otherwise, was fringed his tiffany for this cemetery whirled majored, and spoke ineffectually done for the curtains big heart. Aaa louis vuitton replica Watches wall from aegean mousse faconable east. Batman costume replica robin Near freestyle were again of the tide watches taking who to complete to he, the incident escorted of the time. She so remember am to get from the levi first. Replica panerai watch Mido seemed another swiss other and wore one to watches. Sea pathfinder watches Himself was she improbable, but best always. Citizens had its watches. Panerai submersible replica Uniformly returned a first atlanta into jersey but the replica. Womens Two Tone Watches..
By Replica Watches, at August 07, 2010
i want to have it set so that say a user enters cool2 then it welcomes then like this "welcome joe" and if the user enters it as just cool it says welcome admin or such... understand?
By The Editor, at March 09, 2011
sorry bout the last post, it doesnt seem to work well with blogspot...
By The Editor, at March 12, 2011
Hey there! When I try this, even if you don't enter the right password, adn even if you hit cancel, it still takes you to the password protected page... Did I do something wrong?
By Melissa @ Sweet As Texas Honey, at April 19, 2012
http://blog.infotwistsolutions.com
By Anonymous, at February 02, 2013
that is great work
Try this HTML Tutorials http://mkmovietrailer.blogspot.com/2013/09/html-tutorials.html
By M K D tutorials, at October 30, 2013
this was really helpful. but if you disable javascript, it doesn't protect anything.
By bob, at November 30, 2013
壯陽藥品犀利士樂威壯樂威壯樂威壯樂威壯樂威壯壯陽藥樂威壯壯陽藥壯陽藥壯陽藥成人藥品性藥品性藥品犀利士犀利士犀利士犀利士威而鋼威而鋼威而鋼壯陽藥威而鋼威而鋼威而鋼威而鋼樂威壯犀利士威而鋼威而鋼威而鋼威而鋼壯陽藥品壯陽藥威而鋼威而鋼犀利士犀利士威而鋼樂威壯壯陽藥威而鋼威而鋼壯陽藥情趣藥品春藥犀利士犀利士壯陽藥情趣藥品春藥情色貼圖犀利士威而鋼
By 銘, at March 04, 2014
Thanks for sharing html tips. buy aloe vera toothpaste in india
By Unknown, at February 09, 2015
Really it was an awesome article.very interesting to read..You have provided an nice article.Thanks for sharing.Really very informative and creative contents. These concept is a good way to enhance the knowledge.
By java courses in chennai, at July 26, 2017
It's interesting that many of the bloggers to helped clarify a few things for me as well as giving. Most of ideas can be nice content. The people to give them a good shake to get your point and across the command.
offshore safety course in chennai
By evergreensumi, at December 17, 2018
Wonderful post with great content. Regards to your hard work. I really liked your article. Thanks for sharing.
WordPress Training in Chennai
WordPress Training Chennai
Tally Course in Chennai
Embedded System Course Chennai
C C++ Training in Chennai
Manual Testing Training in Chennai
Oracle DBA Training in Chennai
By Praylin S, at January 02, 2019
Outstanding blog with lots of information. Keep posting more like this.
RPA Training in Chennai
RPA course in Chennai
Blue Prism Training in Chennai
UiPath Training in Chennai
UiPath Training Institutes in Chennai
Data Science Course in Chennai
RPA Training in Velachery
RPA Training in Tambaram
By cynthiawilliams, at January 25, 2019
Outstanding blog thanks for sharing such wonderful blog with us ,after long time came across such knowlegeble blog. keep sharing such informative blog with us.
redmi service center
mi service center
redmi service center near me
redmi mobile service centre in chennai
redmi note service center in chennai
By service care, at February 26, 2019
Such a nice & useful post. Really happy to see such post. I have come to know about many new ideas. I will try my best to implement some of them. Thanks.
Best Ice Fishing Gloves Best Ice Fishing Gloves Best Ice Fishing Gloves
By cdcdcdcd, at March 16, 2019
Your articles really impressed for me,because of all information so nice.cloud computing training in bangalore
By Training for IT and Software Courses, at November 25, 2019
Thanks, Harsh for such a great post. I have tried and found it really helpful.
Bangalore Training Academy is a Best Institute of Salesforce Admin Training in Bangalore . We Offer Quality Salesforce Admin with 100% Placement Assistance on affordable training course fees in Bangalore. We also provide advanced classroom and lab facility.
By Bangalore Training Academy, at December 01, 2019
Very interesting, good job and thanks for sharing such a good blog. Your article is so convincing that I never stop myself to say something about it. You’re doing a great job. Keep it up…
Advance your career as a SharePoint Admin Engineer by doing SharePoint Admin Courses from Softgen Infotech located @BTM Layout Bangalore.
By Softgen Infotech, at December 02, 2019
Post is very useful. Thank you this useful information.
Learn Blue Prism Course from Experts. Softgen Infotech offers the Best Blue Prism Training in Bangalore .100% Placement Assistance, Live Classroom Sessions, Only Technical Profiles, 24x7 Lab Infrastructure Support.
By Softgen Infotech, at December 03, 2019
Nice blog has been shared by you. it will be really helpful to many peoples who are all working under the technology. Thank you for sharing this blog.
AWS training in Chennai
AWS Online Training in Chennai
AWS training in Bangalore
AWS training in Hyderabad
AWS training in Coimbatore
AWS training
By radhika, at August 07, 2020
Good job in presenting the correct content with the clear explanation. The content looks real with valid information. Good Work
oracle training in chennai
oracle training in tambaram
oracle dba training in chennai
oracle dba training in tambaram
ccna training in chennai
ccna training in tambaram
seo training in chennai
seo training in tambaram
By Jayalakshmi, at August 18, 2020
I am really happy with your blog because your article is very unique and powerful for new reader.
java training in chennai
java training in omr
aws training in chennai
aws training in omr
python training in chennai
python training in omr
selenium training in chennai
selenium training in omr
By deiva, at August 22, 2020
Wow, amazing post! Really engaging, thank you.
Data Science Training In Bangalore
Best Data Science Training Institute in Bangalore
By Prwatech, at April 07, 2021
Nice blog and informative content. Keep updating more blogs again soon. If you want to learn a data science course, then follow the below link.
Data Scientist Course in Hyderabad
By Ramesh Sampangi, at March 08, 2022
I am thoroughly impressed by your excellent post and review. Please continue to produce such remarkable content. Thank you!
Best CA Colleges in Hyderabad
By srikanth digital, at June 26, 2023
I'm delighted to express that your post is quite captivating. I've gained fresh insights from your write-up, and you're doing an exceptional job. Keep up the good work. For More Visit the below website
B.Com Colleges in Hyderabad
By srikanth digital, at June 27, 2023
I am delighted to express that your post is captivating to read. I acquire fresh knowledge from your article, and you are doing an excellent job. Please continue your great work.
Best CEC Colleges in Hyderabad
By srikanth digital, at June 28, 2023
I haven't come across such a valuable resource in a long time. It is excellently written and contains incredibly useful information. I truly cannot express my gratitude enough for sharing it.
Degree Colleges in Hyderabad for B.Com
By srikanth digital, at June 30, 2023
Your blog is truly amazing. The content is informative and full of knowledge. I had a great time reading your article. Please continue to share more content like this. Thank you.
B.Com Colleges In Hyderabad
By srikanth digital, at July 01, 2023
Post a Comment
<< Home