Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>There are so many ways you could do this, so the right choice depends on how you're going about everything else.</p> <p>Here are just a few ways of listening, rather than polling.</p> <ol> <li><p>New Chrome Windows</p> <pre><code>function ChromeWindowObserver() { this.observe = function(subject, topic, data) { // subject is a ChromeWindow } } Components.classes["@mozilla.org/embedcomp/window-watcher;1"] .getService(Components.interfaces.nsIWindowWatcher) .registerNotification(new ChromeWindowObserver()); </code></pre></li> <li><p>New Tabs</p> <pre><code>function tabListener(event) { var browser = gBrowser.getBrowserForTab(event.target): } gBrowser.tabContainer.addEventListener("TabOpen", tabListener, false); </code></pre></li> <li><p><a href="https://developer.mozilla.org/en-US/docs/Observer_Notifications" rel="nofollow">Observer Notifications</a> (my favorite)</p> <pre><code>const dumpObserver = { observe: function(subject, topic, data) { dump(topic + "\n"); } } const domObserver = { observe: function(subject, topic, data) { dump(subject.location + "\n"); } } const ObserverService = Components.classes["@mozilla.org/observer-service;1"] .getService(Components.interfaces.nsIObserverService); /* debug log notifications */ ObserverService.addObserver(dumpObserver, "*", false); /* debug log all new content locations */ ObserverService.addObserver(domObserver, "content-document-global-created", false); </code></pre></li> </ol> <p>Side note, check out <a href="https://developer.mozilla.org/en-US/docs/JavaScript_code_modules/Using" rel="nofollow">JavaScript code modules</a>. I think that might be helpful for you when sharing data between chrome windows.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload