dcsimg
www.webdeveloper.com
Results 1 to 4 of 4

Thread: window.location= question

  1. #1
    Join Date
    Nov 2002
    Location
    Cincinnati
    Posts
    5

    window.location= question

    I found this script at javascript.internet.com and have it working (through the help of this forum) except it will not pull up the page that I need it to. I have substituted my usernames, and their passwords for member1 etc.., and the proper page in place of the generic page1, 2, 3 in the script. All I get is the file isn't found. All users will access the same page, not different pages. Can someone help? Thanks

    <!-- Begin
    function Login(){
    var done=0;
    var username=document.login.username.value;
    username=username.toLowerCase();
    var password=document.login.password.value;
    password=password.toLowerCase();
    if (username=="member1" && password=="password1") { window.location="page1.html"; done=1; }
    if (username=="member2" && password=="password2") { window.location="page2.html"; done=1; }
    if (username=="member3" && password=="password3") { window.location="page3.html"; done=1; }
    if (done==0) { alert("Invalid login!"); }

  2. #2
    Join Date
    Nov 2002
    Posts
    12
    If they had a choice between page1 page2 and page3, which page would they be accessing when they get the scripting error?

  3. #3
    Join Date
    Nov 2002
    Location
    Cincinnati
    Posts
    5
    I'm sorry, lets say this is the code below, all users have unique usernames and passwords, but will access the same members.html. I don't see why it won't work, it is basically as I downloaded it except the file they access is the same in all cases. It will work as far as returning the alert if the wrong password is entered.

    if (username=="Elvis" && password=="houndog") { window.location="members.html"; done=1; }
    if (username=="Norm" && password=="cheers") { window.location="members.html"; done=1; }
    if (username=="Coach" && password=="dawber") { window.location="members.html"; done=1; }
    if (done==0) { alert("Invalid login!"); }

  4. #4
    Join Date
    Nov 2002
    Posts
    12
    Well.. hmm.

    Perhaps, as gil suggested in another post, you could try using self.location.replace("xxxx.html")

    If it is not finding the webpage you want, but the webpage exists, I guess just make sure you're targetting the exact location of the page.

    I can't think of any reason why it wouldn't work.. unless Jscript hates successive if statements without any else, in which case you might want if... else if... else if.. and an else statement to support the else if statements...
    if (blah blah == blah) { stuff; done=1; }
    else if (blah blah == blah2) { stuff; done=1; }
    else { done=0; }

    I am not sayin that will work, but that is all i can think of... :/ sry

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