[英]In Chrome extension determine if the user clicked the browser's Back or Forward button
How can I know whether the user clicked back/forward button in Chrome from within my Chrome Extension? 如何知道用户是否在我的Chrome扩展程序中点击了Chrome中的后退/前进按钮?
The only API that could give me any such info is the chrome.webNavigation.onCommitted
which in the case of when the back or forward button are clicked, sends a NavigationQualifier
containing the string 'forward_back'
. 可以给我任何此类信息的唯一API是
chrome.webNavigation.onCommitted
,在单击后退或前进按钮的情况下,发送包含字符串'forward_back'
的NavigationQualifier
。 The problem here is that I'm not able to distinguish between the two buttons. 这里的问题是我无法区分这两个按钮。
You could use the tabs
API's onUpdated
event if that's good enough for you. 您可以使用
tabs
API的onUpdated
事件,如果这对您来说足够好的话。
Alternatively, you could use the HTML5 history API and register a window.onpopstate
handler. 或者,您可以使用HTML5历史记录API并注册
window.onpopstate
处理程序。 Do that from within a content script that runs before the page. 从在页面之前运行的内容脚本中执行此操作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.