Thomas Smyth Thomas Smyth - 1 year ago 72
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

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download