简体   繁体   English

在Chrome扩展程序中,确定用户是否单击了浏览器的“后退”或“前进”按钮

[英]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.

相关问题 如何通过单击angularjs中的浏览器后退/前进按钮来后退/转发用户的历史记录 - how to back/forward user 's history by clicking the browser back/forward button in angularjs JavaScript和浏览器的后退/前进按钮 - JavaScript and the browser's back/forward button 阻止用户使用浏览器的“后退”和“前进”按钮 - Stopping the user from using “Back” and “Forward” button of the browser 单击 Chrome 扩展程序的浏览器操作时将文本复制到剪贴板 - Copy text to clipboard when a Chrome extension’s browser action is clicked 检测浏览器的前进和后退按钮并触发jquery事件 - Detect browser's forward and back button and trigger jquery event 确定是否单击了 Google Chrome 打印预览中的打印/取消按钮 - Determine If Print/Cancel Button in Google Chrome's Print Preview is Clicked 单击后退按钮时是否强制浏览器将用户带到页面的顶部? - Force the browser to take user to the TOP of the page when the back button is clicked? 点击带有Chrome扩展程序的按钮 - Get button clicked with chrome extension GridView 点击浏览器后退按钮后出现排序问题 - GridView Sort Problem after Browser's Back Button Clicked React Router,单击浏览器的后退按钮时的生命周期 - React Router, lifecycle when browser's back button is clicked
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM