如果只有脚本导航,Chrome 历史记录 UI 会变灰?(但 window.history 有效)

Chrome history UI greyed out if there is only script navigation? (but window.history is valid)

提问人:user2771324 提问时间:3/23/2023 更新时间:3/23/2023 访问量:14

问:

我遇到了一个奇怪的问题,即 Chrome 历史记录 UI 变灰,但 window.history 包含有效的历史记录,当由于 js 而创建历史记录时。

(Chrome 111.0.5563.64(64 位),发布时最新)
症状 - Chrome 历史记录界面灰显:

  • Chrome 历史记录 UI - 导航栏和上下文菜单中的后退/前进显示为灰色。
  • 历史记录本身是可以的,window.history.go() 按预期工作

JavaScript 行为:

  1. URL.1 通过以下方式打开 URL.2: in: .window.open(windowFeatures=undefined)<a>/mouse click
  2. URL.2 发送 POST by: in: setTimeout (发生在 window.onload 之后)<input>.click
  3. URL.2(在 POST 之后)通过以下方式重定向到 URL.3:在 setTimeout 中(发生在 window.onload 之后)window.location=xxx

默认行为:UI 灰显。
将 setTimeout() 延迟增加到 1000 毫秒:UI 灰显。
如果将 Step.1 替换为手动导航(打开新选项卡 + 粘贴 URL):UI 正常。 如果将步骤 2 替换为手动单击: ( 在:鼠标点击): UI OK。

如果将 Step.3 替换为手动点击: ( in: 鼠标点击): UI 在点击前显示为灰色;点击后UI正常。
<input>.clickwindow.location=xxx

因此,如果 Chrome 禁用历史 UI,除非涉及用户导航。

在这种情况下如何启用历史 UI?

google-chrome dom 浏览器-历史记录

评论


答: 暂无答案