Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Firefox window.location not working

Status
Not open for further replies.

Phi1Smith

Programmer
Jun 5, 2001
33
0
0
GB
Hi
Could someone tell me why this doesn't work in Firefox, its ok in IE6.

if (username=="name1" && password=="123456") {loggedin=true; window.location="page1.html";}

To check the rest of the script I tried this and it worked in both Firefox and IE6.
if (username=="name1" && password=="123456") {loggedin=true; alert("Correct");}

The redirect url is correct and if I put the full url in that also doesn't work. The script is serverside.

All that appears to happens is the page refreshes, can't find anything about it on mozilla.

Many Thanks

Phil, Firefox fan.
 
what do you mean the script is serverside? JS runs on the client...

*cLFlaVA
----------------------------
[tt]insert funny quotation here.[/tt]
 
Ok its in a .js file not the main document
 
Could you show more complete code? I just tested window.location = ' in FF 1.0 PR and it worked fine.

*cLFlaVA
----------------------------
[tt]insert funny quotation here.[/tt]
 
Hi cLFlaVa
HTML PART
<FORM id="login" name="login" onSubmit="mclogin(document.forms.login.userid.value, document.forms.login.pass.value)">
USERNAME&nbsp;<INPUT id="userid" type="text">&nbsp;
PASSWORD&nbsp;<INPUT id="pass" type="password">
<BUTTON onclick=submit()>Login</BUTTON>

SCRIPT
function mclogin(username, password){loggedin=false;
username=username.toLowerCase();
password=password.toLowerCase();

if (username=="name1" && password=="123456") {loggedin=true; window.location = '
if (loggedin==false) {alert("Login failed!\n\nPlease supply new credentials.");}
}


Thanks for the interest

Phil
 
Try using
Code:
window.location[red].replace([/red]"page1.html"[red])[/red];

--Chessbot

There is a level of Hell reserved for probability theorists in which every monkey that types on a typewriter produces a Shakespearean sonnet.
 
Hi Chessbot

Still no joy, I tried that earlier, just tried it again in case I did it wrong earlier.

here's firefox version
Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.5) Gecko/20041107 Firefox/1.0

Think I'm upto date

Thanks

Phil
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top