MozillaZine

Dev : Extensions : Example Code

From MozillaZine Knowledge Base

(Difference between revisions)
Revision as of 10:05, 31 October 2004
Asqueella (Talk | contribs)
(linking a new page)
<-- Previous diff
Revision as of 10:17, 31 October 2004
Asqueella (Talk | contribs)
(categorize)
Next diff -->
Line 1: Line 1:
-==Preferences==+==XUL==
-[http://xulplanet.com XulPlanet] has an [http://www.xulplanet.com/tutorials/xulqa/q_prefs.html article] on preferences+*[[Dev : Extensions : Example Code : Adding items to menus | Adding items to menus with overlays]]
 +*[[Dev : Extensions : Example Code : Apply button | Adding an Apply button to dialogs]]
-==Progress Listeners== 
-Progress Listeners alllow extensions to be notified of events assosiated with documents loading in the browser and with tab switching events. Progress Listeners implement the [http://www.xulplanet.com/references/xpcomref/ifaces/nsIWebProgressListener.html nsIWebProgressListener] interface. 
-# Create an object which implements nsIWebProgressListener: 
- const STATE_START = Components.interfaces.nsIWebProgressListener.STATE_START; 
- const STATE_STOP = Components.interfaces.nsIWebProgressListener.STATE_STOP;  
- var myListener = 
- { 
- 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(aProgress,aRequest,aFlag,aStatus) 
- { 
- if(aFlag & STATE_START) 
- { 
- //This fires when the load event is initiated 
- } 
- if(aFlag & STATE_STOP) 
- { 
- //This fires when the load finishes 
- } 
- return 0; 
- }, 
- onLocationChange:function(aProgress webProgress , aRequest, aURI) 
- { 
- //This fires when the location bar changes i.e load event is confirmed or when the user switches tabs 
- //return 0; 
- }, 
- //For defnitiions of the remaining functions see XulPlanet 
- onProgressChange:function(a,b,c,d,e,f){}, 
- onStatusChange:function(a,b,c,d){}, 
- onSecurityChange:function(a,b,c){}, 
- onLinkIconAvailable:function(a){} 
- } 
-# Attach the progressListener to a <browser> object, e.g. for firefox: 
- const NOTIFY_STATE_DOCUMENT = Components.interfaces.nsIWebProgress.NOTIFY_STATE_DOCUMENT;  
- window.getBrowser().addProgressListener(myListener , NOTIFY_STATE_DOCUMENT); 
-The second argument is a [http://www.xulplanet.com/references/xpcomref/comps/c_appshellcomponentbrowserstatusfilter1.html status filter] which determines the type of events that will be recieved. 
-==Other==+==Javascript==
-*[[Dev : Extensions : Example Code : Apply button | Adding an Apply button to dialogs]]+===Common===
-*[[Dev : Extensions : Example Code : Adding items to menus | Adding items to menus with overlays]]+*[http://xulplanet.com/ XulPlanet] has an [http://www.xulplanet.com/tutorials/xulqa/q_prefs.html article] on preferences
-*[[Dev : Extensions : Example Code : File IO | File IO]]+
*[[Dev : Extensions : Example Code : Printing to JSConsole | Printing debug information to JavaScript Console]] *[[Dev : Extensions : Example Code : Printing to JSConsole | Printing debug information to JavaScript Console]]
 +*[[Dev : Extensions : Example Code : File IO | File IO]]
 +
 +===<browser> related===
 +*[[Dev : Extensions : Example Code : Progress Listeners | Using progress listeners]]
 +*[[Dev : Extensions : Example Code : On Tab Load | Executing your code each time a page loads]]
 +
 +===Other===
*[[Dev : Extensions : Example Code : Inserting text at cursor | Inserting text at cursor]] *[[Dev : Extensions : Example Code : Inserting text at cursor | Inserting text at cursor]]
*[[Dev : Extensions : Example Code : Using observers | Using observers for cross-window notifications]] *[[Dev : Extensions : Example Code : Using observers | Using observers for cross-window notifications]]
-*[[Dev : Extensions : Example Code : On Tab Load | Executing your code each time a page loads]] 

Revision as of 10:17, 31 October 2004

Contents

XUL


Javascript

Common

<browser> related

Other