/    Sign up×
Community /Pin to ProfileBookmark

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!”); }

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@TheSpiritNov 22.2002 — If they had a choice between page1 page2 and page3, which page would they be accessing when they get the scripting error?
Copy linkTweet thisAlerts:
@JimWauthorNov 22.2002 — 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!"); }
Copy linkTweet thisAlerts:
@TheSpiritNov 22.2002 — 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
×

Success!

Help @JimW spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...