在不发送帖子数据的情况下重新加载带有 #anchor 的页面

Reload page with #anchor without sending post data

本文关键字:加载 #anchor 情况下 数据 新加载      更新时间:2023-09-26

我正在努力刷新带有锚点的页面。

我有一个页面test.php#one并在该页面上发送了一个 POST 表单。如果我确认警报框(我使用自定义警报框),

this.ok = function()
{
    document.getElementById(''dialogbox'').style.display = "none";
    document.getElementById(''dialogoverlay'').style.display = "none";
    window.location.replace(document.URL);
}

框消失,但页面不会刷新。我尝试了谷歌给我的每个结果,但如果 URL 中有锚点,页面根本无法刷新。我很乐意接受任何将页面重新加载到同一锚点并且不会两次发送 POST 表单的解决方案。

感谢您的任何帮助!

我认为这就是你想要的。

window.location.reload(true);