Important alert: (current site time 7/15/2013 2:03:03 PM EDT)
 

VB icon

Password protect a page

Email
Submitted on: 6/5/1998
By: Found on the Web 
Level: Not Given
User Rating: By 101 Users
Compatibility: JavaScript
Views: 22241
 
     How can I password protect a page? The simplist and most effective password protection using just clientside JavaScripting, relies on the user not knowing the target filename. Found on the web at:http://www.irt.org
 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
				
'**************************************
' Name: Password protect a page
' Description:How can I password protect a page? The simplist and most effective password protection using just clientside JavaScripting, relies on the user not knowing the target filename.
Found on the web at:http://www.irt.org
' By: Found on the Web
'
' Inputs:Where frameName1 and frameName2 are the names of the two frames that you want to change. 
'
' Assumes:
Note, the user can find the directory location, by examining the source, therefore you must protect your directory by placing a default file inside it, which your server will always send when the directory is requested, e.g. index.html, otherwise a directory listing will be sent. 
It is also possible on Unix systems, to just set the parent (or all) directory's permissions to rwx--x--x and all other files to rwxr--r--. The user cannot get directory listings, but can still access any files there. (Thanks to Mike Crawford for this last tip.)
'**************************************

<SCRIPT LANGUAGE="JavaScript"><!--
function go() {
window.location.href = "http://www.somewhere.com/" +
document.formName.passwordName.value + '.html';
return false;
}
//--></SCRIPT>
<FORM NAME="formName" onSubmit="return go()">
Enter Password: <INPUT TYPE="password" NAME="passwordName" VALUE="" SIZE=8>
</FORM>
 


Other 219 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Not Given category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments

6/8/1999 4:18:00 PMSeref DANACI

Thanks,
(If this comment was disrespectful, please report it.)

 
8/24/1999 5:27:00 AMnafiz

s

(If this comment was disrespectful, please report it.)

 
8/24/2000 1:46:00 AMdvad78

Did you know that somewhere.com is actually a site? i was playing with this code and i typed in test for the password and it took me to a page... the only thing on the page was the word "wazoo".... Isnt that kinda funny?
(If this comment was disrespectful, please report it.)

 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.