If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Enjoy an ad free experience by logging in. Not a member yet? Register.

Password Protection Code modification

I am using a password protect code from http://javascriptkit.com/script/cut34.shtml . The code works perfect for me since i need to have different passwords to access different pages in the same interface, and here the password is the name of the html files.

Concept Used: The pop up window asks for password and then looks for an html file with the same name in the root folder. If there is no such file then the pop up stays and the base page returns again.

Modification Needed: I want to make the code look for the html file in a specific folder instead of in the root.

I changed the 5th line of the following code to make it location=\/folder\/password +".html"

But it does not work. Kindly suggest me my mistake. needless to say that I am a beginner. Your help shall be highly appreciated. Thanks

Thank You.

Thank you so much. The first one worked.

By entering the wrong password it tries to open the respective non existent html file in the folder in the directory. and stays there with a file not found page. Is there any way in using javascript, the page can be redirected to a predefined page when the user enters a password(wrong), and no such html file exists in the folder ?

A thought occurs that you could try to load the page in a hidden iframe, using onload to try to reference an element on the page, even document.body, and if this fails redirect to another page. But I don't know without a little googling whether onload fires if the page is not found(?).

[I think there might be another way to do this using ajax or some other similar technology.]

But given that this is not secure at all.. you could store the passwords in an array and check if the one they've entered exists in the array.

"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
Validate your HTML and CSS

Thank you Andrew. That seems to be a clever idea. I do not have adequate know how to execute that though. I am getting the files hosted and hopefully configuring a 404 not found page might help. I will continue to investigate. Thank you again.

Yes I was reading a little further. If you provide your own 404 page then there will be something on the page that you can refer to that identifies it. Or, of course, this 404 page could offer to redirect the user.

I had what I thought was a clever idea, which was to wait for onload to complete and just read the location (the address); if it's different then the page they were seeking doesn't exist. But I don't know if this would work. Something like:

and then put the contents of the above code in the password seeking pop up window.
What else do i need to do to achieve the redirection back to the predefined page.. where in the code does it define the predefined page.

I am not sure.. When I put the code in the popup then it shows a messagebox in the pop up itself, as soon as it loads and on clicking ok, takes me to the dump (dragto.html)... but the user never gets to input the password...

Here is the file structure I am using
Webroot
-index.html (the homepage)
-dragto.html ( refered to as dump)
-gate.html (the pop up )
-Codebox
--xyz.html (refered to as treasure)

The desired behavior is on clicking a button in index.html it opens the gate.html as a pop up. Then if you put xyz as the password in the popup, it takes you to /Codebox/xyz.html but entering anything else should take you to dragto.html.

I added the above code to the pop up file and placed a carousel.html in the root drive. But I am not getting the desired result. It does not give a chance to enter the password and then takes to the dragto.html everytime... May be I am missing something here.