NavigationActivation:navigationType 属性

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

实验性: 这是一项实验性技术
在将其用于生产之前,请仔细检查浏览器兼容性表格

NavigationActivation 接口的 navigationType 只读属性包含一个表示导航类型的字符串。

表示 NavigationActivation 所关联的导航类型的字符串。可能的值包括:

  • push:导航到新位置,导致新条目被推送到历史记录列表中。
  • reload:重新加载 NavigationActivation.entry
  • replace:用新历史记录条目替换 NavigationActivation.entry。此新条目将重用相同的 key,但分配不同的 id
  • traverse:浏览器从一个现有历史记录条目导航到另一个现有历史记录条目。

示例

js
window.addEventListener("pageswap", (event) => {
  // 例如,页面被隐藏,或者导航是跨文档的。
  if (!event.viewTransition) return;

  // 跳过后退/前进导航的视图转换。
  if (event.activation.navigationType === "traverse") {
    event.viewTransition.skipTransition();
  }
});

规范

Specification
HTML
# dom-navigationactivation-navigationtype

浏览器兼容性

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
navigationType
Experimental

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
No support
No support
Experimental. Expect behavior to change in the future.

参见