Javascript

  • sly1340
  • Graduate
  • Graduate
  • User avatar
  • Posts: 238
  • Loc: not available

Post 3+ Months Ago

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
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • this213
  • Guru
  • Guru
  • User avatar
  • Posts: 1260
  • Loc: ./

Post 3+ Months Ago

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
  • Posts: 776
  • Loc: Nippon

Post 3+ Months Ago

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
  • Posts: 1121
  • Loc: Boston

Post 3+ Months Ago

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.
  • sly1340
  • Graduate
  • Graduate
  • User avatar
  • Posts: 238
  • Loc: not available

Post 3+ Months Ago

awesome

now how can i get the text to be bullets
  • RichB
  • Guru
  • Guru
  • User avatar
  • Posts: 1121
  • Loc: Boston

Post 3+ Months Ago

Change it from type="text" to type="password"
  • Nem
  • Guru
  • Guru
  • Nem
  • Posts: 1243
  • Loc: UK

Post 3+ Months Ago

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

Thats a bit security risk your taking...
  • Rat
  • Guru
  • Guru
  • User avatar
  • Posts: 1190
  • Loc: desk

Post 3+ Months Ago

Yes it will show in the source code. That is very insecure.
  • SpooF
  • ٩๏̯͡๏۶
  • Bronze Member
  • User avatar
  • Posts: 3422
  • Loc: Richland, WA

Post 3+ Months Ago

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
  • Posts: 238
  • Loc: not available

Post 3+ Months Ago

thanks guys

Post Information

  • Total Posts in this topic: 10 posts
  • Users browsing this forum: No registered users and 57 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
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.