Thomas Smyth
Thomas Smyth

Reputation: 522

`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 thomas-smyth.co.uk, so I have tried the following piece of code to redirect the user.

window.location.href = "http://thomas-smyth.co.uk/home.php";

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

Thanks in advance, Tom

Upvotes: 0

Views: 951

Answers (1)

Ben
Ben

Reputation: 683

You have posted the wrong code. In your Js File thomas-smyth.co.uk/functions/login.js on your webserver is this:

//Re-directs to subdomain.
window.location.href = "http://www.thomas.smyth.co.uk/home.php";

this should be fixed to

//Re-directs to subdomain.
window.location.href = "http://thomas-smyth.co.uk/home.php";

@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.

Upvotes: 2

Related Questions