Bonjour,

je dois faire pour la première fois une extension Firefox. Et j'avoue que je galère un peu.
Cette extension doit à partir d'un tableau où sont stockés des liens, récupérer le document associé.
Pour cela j'utilise un Progress listener. Voila mon code.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
 
// Create an object which implements nsIWebProgressListener
const STATE_START = Components.interfaces.nsIWebProgressListener.STATE_START;  
const STATE_STOP = Components.interfaces.nsIWebProgressListener.STATE_STOP; 
 
myExt_urlBarListener = {  
    QueryInterface: function(aIID)  
    {  
      if (aIID.equals(Components.interfaces.nsIWebProgressListener) ||  
           aIID.equals(Components.interfaces.nsISupportsWeakReference) ||  
           aIID.equals(Components.interfaces.nsISupports))  
         return this;  
       throw Components.results.NS_NOINTERFACE;  
    },  
 
    onStateChange: function(aBrowser, aWebProgress, aRequest, aStateFlags, aStatus)  
    {  
		// If you use myListener for more than one tab/window, use  
		// aWebProgress.DOMWindow to obtain the tab/window which triggers the state change  
		if(aStateFlags & STATE_START)  
		{  
			// This fires when the load event is initiated  
		}	  
		if(aStateFlags & STATE_STOP)  
		{  
			// This fires when the load finishes  
			var document = browser.contentDocument;
			// j'affiche par exmple le titre
			alert("titre "+document.title);
		}
	} 
};
 
Zotero.GenerationFichierDonnees = {  
	// fonction principale qui est appelee quand l'utilisateur appuie sur la bouton "Generation fichiers de donnees" dans zotero 
	init: function() 
	{
 
		gBrowser.addTabsProgressListener(myExt_urlBarListener);
		var tablien = new Array("www.google.fr",);
		for (i=0; i<tablien.length; i++)
		{
			gBrowser.addTab("zotero://attachment/"+itemIDHighLight[i]["itemID"]+"/");
		}	
	},
 
}; 
 
window.addEventListener("load", function() {Zotero.GenerationFichierDonnees.init()}, false);  
window.addEventListener("unload", function() {Zotero.GenerationFichierDonnees.uninit()}, false);
Mais ce code a quelques problèmes.
Il affiche plusieurs fois de suite le même titre pour un même onglet.
Et je comprends pas pourquoi ?
Ca fait quelque temps que je cherche et je commence à désespérer.

Merci d'avance !!