自定义光标在使用 window.history.replaceState 时闪烁

Custom cursor blinking when using window.history.replaceState

本文关键字:history replaceState 闪烁 window 光标 自定义      更新时间:2023-09-26

我在子页面之间导航时使用window.history.replaceState方法来替换URL。我在我的 Web 应用程序中使用自定义光标,当我用新 URL 替换当前 URL 时,我的自定义光标会闪烁一小会儿(我可以看到它被光标:默认替换)。有什么办法可以防止这种情况还是正常行为?谢谢你的回答。

编辑:这是在Chrome浏览器中发生的,在IE11自定义光标不闪烁。

对我来说

听起来像个错误!

将鼠标悬停在普通链接上时,

我得到了相同的行为(使用将鼠标悬停在链接上时获得的正常"指针"图标。

我提交了一个铬错误:https://bugs.chromium.org/p/chromium/issues/detail?id=1128213

下面是一个简单的测试用例来重现:

setInterval(
  function() {
    window.history.replaceState('', '', window.location.pathname);
  },
  100
);
a {
  display: block;
  height: 300px;
  width: 300px;
  background: #3af;
}
<a href="#">Hover me! Does your cursor flicker and/or wiggle?</a>