Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

window.location.href going a folder back?

So I have a html document that is located at localhost/r/index.php, but when I do window.location.href="localhost" it sends me to locahost/r/localhost which I don't want. I want my script to send me to localhost. Is there a way to do this?

like image 840
Elias Konrad Avatar asked Dec 03 '22 21:12

Elias Konrad


2 Answers

You use / to denote the root directory of your webserver:

window.location.href="/";

Or, you can use a full url:

window.location.href="http://localhost";
like image 55
stelioslogothetis Avatar answered Dec 06 '22 12:12

stelioslogothetis


window.location.href="localhost" => window.location.href="/"

like image 35
kyun Avatar answered Dec 06 '22 10:12

kyun