[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Javascrip password code

Posted on 2004-11-10
6
Medium Priority
?
363 Views
Last Modified: 2010-08-05
Hey

i have this code:

<a href="page1.htm" onclick="ConfirmPassword( this ); return false;" > Enter </a>

<script type="text/javascript">
<!--
{
        // get the password
        var strPassword = prompt( "Please Enter Password Here" );

       // Go to the password protected page
       window.location.href = "www.domain.com/" + strPassword + "/" + objTargetLink.href;
}
-->
</script>

which only allows people to view my page, if they enter a correct password. i have a few problems with it i am using dw mx 2004.

1. the page loads and then asks for the password so people can see the contents of the page when it asks for the password.
2. the word undifined appears in the password slot, how do i define my password?

any help would be appreciated

thank you

gary

0
Comment
Question by:garypyne
  • 3
  • 3
6 Comments
 
LVL 10

Accepted Solution

by:
Bustarooms earned 400 total points
ID: 12548905
well the undefined thing is solved by this

// get the password
       var strPassword = prompt( "Please Enter Password Here", "" );


the second attribute is the default value for the field

is this the exact code you have on the page?  if so, you fogot to give the function you made a name.  it should be


<script type="text/javascript">
<!--
function ConfirmPassword(objTargetLink){
       // get the password
       var strPassword = prompt( "Please Enter Password Here" );

      // Go to the password protected page
      window.location.href = "www.domain.com/" + strPassword + "/" + objTargetLink.href;
}
-->
</script>
0
 

Author Comment

by:garypyne
ID: 12549201
thanks it all woked, but now i dont know how to chnage the pass, where do i enter the passsword i want to use?

ty

gary
0
 
LVL 10

Expert Comment

by:Bustarooms
ID: 12549271
umm, well what you have setup is going to do the following,

user clicks on the link and they will be prompted for a password. they enter that password, and then you send them to the page http://www.domain.com/[whater they typed goes here]/page1.htm

so if i typed "garypyne"  in the prompt, i would be taken to "http://www.domain.com/garypyne/page1.htm"

so, if that was not the right "password" i would get a broken page, if it was right, I would go to a page that works.

This is NOT a good way of doing a password protected site by any means.  In fact, if you are looking to truly password protect your site, Javascript is not your answer, it needs to be client side.
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Author Comment

by:garypyne
ID: 12549399
is page1 just an example or does it automatically oipen that one first, if not can u set it to which page it opens first?

ty

gary
0
 
LVL 10

Expert Comment

by:Bustarooms
ID: 12549415
that's in there b/c that's what you had in your code.

i would suggest changing it to

 // Go to the password protected page
      window.location.href = "www.domain.com/" + strPassword + "/"

and if that's the right directory, you'll have the correct index.html page there
0
 

Author Comment

by:garypyne
ID: 12549505
ok im so confused right now.

at the moment i have this code

 <a href="page1.htm" onclick="ConfirmPassword( this ); return false;" > Enter</a>

<script type="text/javascript">
<!--
function ConfirmPassword(objTargetLink){
       // get the password
       var strPassword = prompt( "Please Enter Password Here", "");

      // Go to the password protected page
      window.location.href = "http://3xd.recongamer.com/hkrules" + strPassword + "/" + objTargetLink.href;
}
-->
</script>

ok i think this is all correct. this is the website url:

http://3xd.recongamer.com/hkrules

and that is the folder where my protected page is (by the way, theres nothing of importance so im using java cos its supposedly the quickest and easiest :P)

i have a page in there called test.htm

and i want the password to be "hkrules" which is the folder name, therefore th password as well. i inserted this on my website and uploaded it, all it done was display the password i had written in a windows error box, but all it said was the password i ahd eneterd. for example if i entered "pass" as the password the box would show me "pass" and thats it. it did not link me to any pages at all.

is there any chance you could show me exactly what to do.

thank you for all your help so far i really appreciate it

ty

Gary
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question