所以我有一个位于 的 html 文档localhost/r/index.php,但是当我这样做时,window.location.href="localhost"它会将我发送到locahost/r/localhost我不想要的位置。我希望我的脚本将我发送到localhost. 有没有办法做到这一点?
你/用来表示你的网络服务器的根目录:
window.location.href="/";
Run Code Online (Sandbox Code Playgroud)
或者,您可以使用完整的网址:
window.location.href="http://localhost";
Run Code Online (Sandbox Code Playgroud)