Elias Konrad Elias Konrad - 3 years ago 187
HTML Question

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?

Answer Source

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";
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download