1

I'd like to do the equivalent of chrome.tabs.onUpdated in Firefox. tabs.on('ready', function(tab){}) does not work because it does not detect the back button. How do I fire an action on every page load such that it also detects the back button using the Firefox SDK?

4

4 回答 4

0

You'd have to use require('window-utils').WindowTracker to all windows, filter for browser windows with the require('sdk/window/utils').isBrowser(window) method, then listen to click events on the back button.

于 2013-02-07T12:31:09.390 回答
0

It's currently impossible, but will be possible in a future version of Firefox: https://github.com/mozilla/addon-sdk/commit/e4ce238090a6e243c542c2b421f5906ef465acd0

于 2013-04-04T17:13:09.920 回答
0

A bit of a late answer, but for anyone reading this now (from 2016), it is now possible to do using the SDK!

Using the High-Level API tabs, you need to listen for the pageshow event. (More about this on MDN)

An example:

tabs.on('pageshow', function(tab) {
    // Your code here
})

It is very similar to the load and ready events, the main difference being that is is also fired when a page is loaded from BFCache (which it is when the back button is pressed).

于 2016-01-20T09:12:21.870 回答
-1

I think the following snippet gives the functionality of chrome.tabs.onUpdated

var tabs = require("sdk/tabs");
tabs.on('ready', function(tab){
  console.log(tab.url);
});
于 2013-02-06T21:23:20.773 回答