Capturing page loaded events from a Firefox extension

One of my hacks at Over The Air was an attempt to sync browser histories between desktop and mobile. A part of this was a Firefox extension which listens for when I go to a new webpage, gets the URL from the Firefox address bar and sends it to a connected mobile.

As my first attempt at a Firefox extension, I was surprised by how easy this was. I’ve made it, so if anyone wants to learn or build on it, downloading the source may be useful. (Remembering it was thrown together in a bit of a hurry!) But I wanted to highlight a couple of quick points.

Firstly – getting started. Owen pointed me at a brilliant Firefox extension wizard. Fill in the simple form – telling it stuff like whether you want to add an options dialog and preferences, or a context menu item, or a toolbar button, and so on. And it generates you a skeleton Firefox extension ready for you to fill in with code. This probably saved me an hour or two of reading about how to create Firefox extensions!

Secondly – capturing new pages. This was done by adding a listener for DOMContentLoaded events:

var appcontent = window.document.getElementById("appcontent");

And in my content loaded function, I got the URL like this:

var urlbar = document.getElementById('urlbar');

Tags: ,

2 Responses to “Capturing page loaded events from a Firefox extension”

  1. Sapiens says:

    This does not seem to work on 3.0.1 wonder if im doing something wrong

  2. Rolf says:


    Would be pretty to make an extension plays a sound if page loaded. 😉