Thomas Smyth Thomas Smyth - 11 months ago 43
Javascript Question

window.location.href not working as intended

I'm using a javascript along with php to create a login system for a project I'm working on.

I have everything working in regards to actually logging the user in and then checking this within my javascript, however when I redirect the user from the login page to a private page I'm having issues with window.location.href in the javascript.

I own the domain, so I have tried the following piece of code to redirect the user.

window.location.href = "";

However, when this redirects me it is redirecting me to, which obviously causes the page not to load. Any ideas on how I could fix this?

Thanks in advance,

Ben Ben
Answer Source

You have posted the wrong code. In your Js File on your webserver is this:

//Re-directs to subdomain.
window.location.href = "";

this should be fixed to

//Re-directs to subdomain.
window.location.href = "";

@vlaz mentioned right, you have a second mistake with a wrong dot instead of a dash

And btw you should explain your problem a bit more. More code would be usefull next time if you want some help.