www.webdeveloper.com
Results 1 to 3 of 3

Thread: PASSWORD script HELP

  1. #1
    Join Date
    Oct 2011
    Location
    Hamilton, Ontario
    Posts
    84

    PASSWORD script HELP

    hey I've been can't tell what I'm missing here, any suggestions?.. trying to get it so that this function is run each time someone clicks a link that leads them to another page in my site and this is my attempt to make this script external so that when someone goes to one of those pages it runs the script only until they enter the correct password and after the correct password is entered they don't have to do it again until they leave the site and come back again:

    script: (passscript.js)

    function passcheck(page) {
    for (var password==""){
    password = prompt("Please enter the password", "");
    if (password!="sample password"){
    window.location="filepath/test.html"
    }
    else{
    window.location="filepath/" + page + ".html"
    break;
    }
    }
    }

    html: (test.html)

    <html>
    <head>
    <title>Title</title>
    <script language="javascript" src="passscript.js">
    </script>
    </head>
    <body>
    <a href="test2.html" onclick="passcheck('test2')" />next page</a>
    </body>
    </html>

  2. #2
    Join Date
    Jul 2012
    Location
    UK
    Posts
    15
    Change this:
    Code:
    <a href="test2.html" onclick="passcheck('test2')" />next page</a>

    To this:
    Code:
    <a href="javascript: passcheck('test2');">next page</a>
    Also you are missing some semicolons in your JavaScript statements which may cause confusion
    And shouldn't this
    Code:
    for (var password==""){
    Be an if statement:
    Code:
    If (var password==""){
    Last edited by xxxfirehazrd; 08-08-2012 at 06:02 PM.

  3. #3
    Join Date
    Aug 2012
    Location
    Belgium
    Posts
    66
    Password checking threw javascript is not secure.
    Better done server side

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles