You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何检测浏览器标签页从历史记录中恢复的事件?

如何检测标签页何时从历史记录中恢复?

单个标签页恢复的检测方式

当恢复单个标签页时,可以在chrome.tabs.onCreated事件监听中,检查标签页对象的pendingUrl属性:

chrome.tabs.onCreated.addListener(tab =>
{
  console.log("restored", tab.pendingUrl && tab.pendingUrl === tab.url);
});

当pendingUrl存在且与tab.url相等时,即可判定该标签页是从历史记录中恢复的。

Edge浏览器的兼容性问题

在Edge v119.0.2151.58版本中,若恢复的是整个窗口,此时每个标签页触发onCreated事件时,pendingUrl属性会不可用,上述方法无法生效。

内容的提问来源于stack exchange,提问作者vanowm

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.06 06:23:10