Javascript

  • sly1340
  • Graduate
  • Graduate
  • User avatar
  • Joined: Dec 03, 2003
  • Posts: 238
  • Loc: not available
  • Status: Offline

Post July 2nd, 2004, 4:47 pm

whats wrong with this script

Code: [ Select ]
<html>
<title>Javascript</title>
<head></head>
<script language="Javascript">


function id()
{
if (document.form.pw.value == "sly1340" )
{
parent.location (" http://www.htmlgoodies.com");
}
else
{
document.write ("Invalid password");
}
}
</script>
<body>  
<FORM NAME="form" action="">
Enter password
<INPUT TYPE="text" NAME="pw">
<p>
<INPUT TYPE="button" VALUE="submit"
onClick=" id()" >
</form>
</body>
</html>
  1. <html>
  2. <title>Javascript</title>
  3. <head></head>
  4. <script language="Javascript">
  5. function id()
  6. {
  7. if (document.form.pw.value == "sly1340" )
  8. {
  9. parent.location (" http://www.htmlgoodies.com");
  10. }
  11. else
  12. {
  13. document.write ("Invalid password");
  14. }
  15. }
  16. </script>
  17. <body>  
  18. <FORM NAME="form" action="">
  19. Enter password
  20. <INPUT TYPE="text" NAME="pw">
  21. <p>
  22. <INPUT TYPE="button" VALUE="submit"
  23. onClick=" id()" >
  24. </form>
  25. </body>
  26. </html>
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post July 2nd, 2004, 4:47 pm

  • this213
  • Guru
  • Guru
  • User avatar
  • Joined: Mar 01, 2004
  • Posts: 1242
  • Loc: ./
  • Status: Offline

Post July 2nd, 2004, 9:44 pm

you're trying to use a reserved keyword for the name of your function. Rename it to something like "getid" or "thisid" or something other than "id"
  • gsv2com
  • Professor
  • Professor
  • User avatar
  • Joined: Jan 25, 2004
  • Posts: 776
  • Loc: Nippon
  • Status: Offline

Post July 3rd, 2004, 1:56 am

That code is also very, very not secure. Why would you ever use JavaScript for a password script?! All anybody has to do is view source to get the password.
  • RichB
  • Guru
  • Guru
  • User avatar
  • Joined: May 17, 2003
  • Posts: 1121
  • Loc: Boston
  • Status: Offline

Post July 3rd, 2004, 5:05 am

I agree with what's been said so far. There is also an error in the use of parent.location because you've got it as a function call with the location string being passed as an argument to a function, but parent.location is a property so you would just assign in with the assignment operator:

Code: [ Select ]
parent.location = "http://www.htmlgoodies.com";


Also I think you would want to use an alert box rather than document.write for the invalid password message. I'm not sure how well that will work when you're calling it from inside the event handler of a button.
Free Programming Resources
  • sly1340
  • Graduate
  • Graduate
  • User avatar
  • Joined: Dec 03, 2003
  • Posts: 238
  • Loc: not available
  • Status: Offline

Post July 3rd, 2004, 8:14 am

awesome

now how can i get the text to be bullets
  • RichB
  • Guru
  • Guru
  • User avatar
  • Joined: May 17, 2003
  • Posts: 1121
  • Loc: Boston
  • Status: Offline

Post July 3rd, 2004, 9:32 am

Change it from type="text" to type="password"
Free Programming Resources
  • Nem
  • Guru
  • Guru
  • No Avatar
  • Joined: Feb 13, 2004
  • Posts: 1243
  • Loc: UK
  • Status: Offline

Post July 3rd, 2004, 9:48 am

wont the password show in the source code once on the net?

Thats a bit security risk your taking...
GSDomains.com -Click here - Packages starting from £3.69 a month. 1.5GB Space & 10GB Bandwidth.
  • Rat
  • Guru
  • Guru
  • User avatar
  • Joined: Apr 25, 2004
  • Posts: 1190
  • Loc: desk
  • Status: Offline

Post July 3rd, 2004, 10:18 am

Yes it will show in the source code. That is very insecure.
  • SpooF
  • ٩๏̯͡๏۶
  • Bronze Member
  • User avatar
  • Joined: May 22, 2004
  • Posts: 3415
  • Loc: Richland, WA
  • Status: Offline

Post July 3rd, 2004, 1:16 pm

basicly you could make a page like this

Code: [ Select ]
<FORM NAME="form" action="">
Enter password
<INPUT TYPE="text" NAME="pw" VALUE="sly1340">
<p>
<INPUT TYPE="button" VALUE="submit"
onClick=" id()" >
</form>
  1. <FORM NAME="form" action="">
  2. Enter password
  3. <INPUT TYPE="text" NAME="pw" VALUE="sly1340">
  4. <p>
  5. <INPUT TYPE="button" VALUE="submit"
  6. onClick=" id()" >
  7. </form>


its basicly not even worth making that, inless its just to see if something like that will work, but i dont use it on the web
  • sly1340
  • Graduate
  • Graduate
  • User avatar
  • Joined: Dec 03, 2003
  • Posts: 238
  • Loc: not available
  • Status: Offline

Post July 3rd, 2004, 7:44 pm

thanks guys

Post Information

  • Total Posts in this topic: 10 posts
  • Users browsing this forum: No registered users and 176 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
cron
 

© 2011 Unmelted, LLC. Ozzu® is a registered trademark of Unmelted, LLC.