質問

I'm trying to write a simple little addon for Firefox Mobile, starting from this skeleton. Ultimately I'd like to be running a bit of code against every new page loaded, which seems to be best accomplished by adding a "DOMContentLoaded" listener to every new tab, which fires when that tab loads a new page. To that end I need to detect new tabs, which is apparently in turn done by adding a "TabOpen" listener to the BrowserApp's deck.

Problem: At startup (but not when installing into an already loaded session), window.BrowserApp.deck is null for the only window. The documentation, what little there is, doesn't seem to suggest this is possible.

To test this yourself, download the skeleton linked above and add

window.NativeWindow.toast.show(window.BrowserApp, "long");

below line 48 of bootstrap.js, then build, install on Mobile Firefox, and restart. You'll see a toast reporting BrowserApp's properties, including 'deck: null'. (I'm also currently hosting a copy of the extension you'll so obtain on my server, which is be much quicker to test: just point your Mobile Firefox browser to that link, install, and restart.)

What gives? Am I misreading something? Is there a better way of doing what I'm trying to do which won't run into this problem? Is there more extensive documentation somewhere?

役に立ちましたか?

解決

Wait for the UIReady event.

window.addEventListener("UIReady", function(){your code}, false);
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top