我知道怎么去链接/url/地址,比如;
window.location = "www.example.com/index.html";
或者
document.location.href="www.example.com/index.html";
但是假设我想从 to 导航index1.html,index2.html我如何在不提供www.example.com/前缀的情况下实现这一点?请不要建议我设置www.example.com/一个全局变量/常量。地址可能会更改为www.example2.com/subfolder1/subfolder2/....www.examplea.com/上述方法仅适用于根页面。我的意思是document.location.href="index.html";,rootdomain/index.html即使我住在rootdomain/section1/section2/somepage.html. 但我想导航到rootdomain/section1/section2/index.html
我怎样才能通过只提供页面名称来实现这一点?