des*_*r87 7 html javascript browser
我曾经通过使用window.performance.navigation.typelike来单击上一页中的后退按钮来确定用户是否来过
if (window.performance.navigation.type === 2) {
window.location.reload()
}
Run Code Online (Sandbox Code Playgroud)
我看到此属性已被Navigation Timing Level 2弃用并成功。我怎样才能通过这个模仿 performance.navigation api 的行为?
Cra*_*igF 12
我应该先声明我不是 JavaScript 专家。这是我使用Navigation Timing Level 2 的方法。
if (String(window.performance.getEntriesByType("navigation")[0].type) === "back_forward") {
window.location.reload()
}
Run Code Online (Sandbox Code Playgroud)
window.performance.getEntriesByType("navigation")返回每个标记集的 PerformanceEntry 对象列表。如果您尚未设置任何标记,则此列表包含一个具有窗口导航信息的对象。
| 归档时间: |
|
| 查看次数: |
5899 次 |
| 最近记录: |