NavigateEvent:userInitiated 属性
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
NavigateEvent
接口的 userInitiated
只读属性在导航是由用户发起的(例如,通过单击链接、提交表单或按浏览器的“后退”/“前进”按钮)时返回 true
,否则返回 false
。
备注:
附录:导航类型中的表格显示了哪些导航类型是由用户发起的。
值
布尔值——如果导航是由用户发起的,则为 true
,否则为 false
。
示例
js
navigation.addEventListener("navigate", (event) => {
console.log(event.userInitiated);
});
规范
Specification |
---|
HTML # dom-navigateevent-userinitiated-dev |
浏览器兼容性
BCD tables only load in the browser
参见
- 现代客户端路由:导航 API
- 导航 API 说明
- Domenic Denicola 的导航 API 在线演示