我正在使用 JavaScript 函数通过以下命令将窗口重定向到不同的网页:
window.location.replace("/EluLander/doctor/doctordash.html");
这是我手动打开网页时的网址:
file:///C:/Users/Elijah%20Spiegel/Desktop/EluLander/doctor/doctordash.html
我重定向的页面的 URL 是这样的:
file:///C:/Users/Elijah%20Spiegel/Desktop/EluLander/Landingpage.html
当我运行该函数时,它会引导我
file:///C:/EluLander/doctor/doctordash.html
我在搞什么鬼?
最佳答案
替换功能完全正常。由于您没有使用网络服务器,因此 file:///C:/
充当主机。
要使重定向正常工作,请将代码更改为:
window.location.replace("/Users/Elijah%20Spiegel/Desktop/EluLander/doctor/doctordash.html")
关于javascript - 窗口重定向困惑,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27727036/