Facebook Twitter

On page load - MDC. This article is for XUL/JavaScript developers who want to have custom code executed each time a new page is loaded in browser/mail.

On page load - MDC

If you need finer control over custom code execution—for example, as documents are loading or when tabs are switched—see Progress Listeners. Progress listeners allow extensions to be notified of events associated with documents loading in the browser and with tab switching events. Progress listeners implement the nsIWebProgressListener interface. Creating an overlay. Mobile/Fennec/CodeSnippets.

Here you should find a set of useful code snippets to help you work with Fennec.


Although Fennec is built on XUL and JS, like Firefox, the architecture between Firefox and Fennec is different. Each snippet normally includes some code to run at initialization. These are best run using a load listener. These snippets assume they are run in the context of a browser window. Load Listener. Detecting page loads in a Firefox Extension. Posted: September 15th, 2008 | Author: Tim | Filed under: coding, firefox extensions | Tags: addeventlistener, detecting, event, Firefox Extension, gbrowser, page loads | 4 Comments » Detecting page loads is a useful ability.

It’s easy enough to throw in a gBrowser.addEventListener(“load”, function_name, true); DOMContentLoaded. Progress Listeners - MDC. Progress Listeners Progress listeners allow extensions to be notified of events associated with documents loading in the browser and with tab switching events.

Progress Listeners - MDC

Progress listeners implement the nsIWebProgressListener interface. Note that if you just want to execute your code each time a page loads, you can use an an easier method, onPageLoad(). Note that onPageLoad does not fire for back button clicks. In the examples below the progress listener is attached to the tabbrowser, which means you don't get any notifications for inactive tabs. AddProgressListener for ALL Tabs?! This is frustrating me.

addProgressListener for ALL Tabs?!

How come the progress listener does not get called for a page loading in a tab that does not have focus?! I can't figure out why the Mozilla interface doesn't support this. The "close" event handler is not working, any help. I got my close event worked..

The "close" event handler is not working, any help

All I worked was, removed the "alert()"s and it worked a couple of times. But again started not to work.. I then removed try{} and catch{} blocks (catch again had an "alert()") and it works every time now. How to get tab id from "DOMContentLoaded" event, Firefox - Unix. JavaScript Kit- Event Object. Event Object Last updated: March 15th, 2009 The Event object keeps tracks of various events that occur on the page, such as the user moving the mouse or clicking on the link, and allows you to react to them inside your scripts.

JavaScript Kit- Event Object

Related Tutorials. [Project_owners] Getting Source Tab When Listening to http-on-mo. Gecko-Specific DOM Events - MDC. Events - MDC. « XUL Reference home The following tables describe the event handler that are valid for most XUL elements.

Events - MDC

The events listeners can be attached using addEventListener and removed using removeEventListener. Some of the events can be attached using attributes as well. AddProgressListener for ALL Tabs?! Getting a Progress Listener to work. Following from the Event listeners & logging browsing session this topic is about the NSIWebProgressListener object.

Getting a Progress Listener to work

And then tried to incorporate a progress listener to my overlay. The resulting code is below and it didn't work. My questions are at the bottom of this post and perhaps they are not so much specific to my extension, so before troubling reading the following code just skip to the end of the post. Code: Select all const STATE_START = Components.interfaces.nsIWebProgressListener.STATE_START;const STATE_STOP = Components.interfaces.nsIWebProgressListener.STATE_STOP;window.addEventListener("load", function(e) {myext.onLoad(e);}, false);

How to add ProgressListener to each Tab. Hi, guys, I am just starting to learn FF ext, I am trying to add ProgressListener to each Tab when Tab is created, then record some browsing history for each tab, for example, last visited url, load counts, etc, so if I have 5 opened tabs, I should have 5 records for last visited url, load counts, etc.

How to add ProgressListener to each Tab

What I am doing right now is: 1. add load and unload event listeners for window, when window load, I add tabcontainer listener to catch actions to tab. Code: Select all. Event listeners & logging browsing session. Hello, I am developing an extension that should log user browsing behavior. Things that I am interested in are parameters like: url's browsedlink clickthroughtime spent on pageisbookmarkedetc What I have considered to do is use a function appendLog(url) on every page/tab load. There are several sample codes provided in the MDC but in order not to register log entries on every new window load or frame load i have used the solution proposed in: But I cannot get this to work. There are two event listeners attached on window loads.