Code Snippets for Firefox (from MDN)

  1. Code snippets – MDN

    https://developer.mozilla.org/en/Code_snippets
    20 Mar 2012 – This is a quick list of useful code snippets (small code samples) available for developers of extensions for the various Mozilla applications.

  2. Code snippets Alerts and Notifications – Mozilla Developer Network

    https://developer.mozilla.org/en/Code…/Alerts_and_Notifications
    16 Sep 2010 – Pop-ups. notify.png. The following code presents a non-modal pop-up, which automatically disappears after an appropriate delay. It uses

  3. Code snippets Tree – Mozilla Developer Network

    https://developer.mozilla.org/en/Code_snippets/Tree
    2 Jul 2010 – Expanding/Collapsing all tree nodes. To expand all tree nodes: var treeView = tree.treeBoxObject.view; for (var i = 0; i < treeView.rowCount

  4. Code snippets Customizing the download progress bar

    https://developer.mozilla.org/…/Customizing_the_download_progres
    17 Nov 2009 – This example illustrates how to customize the progress bar displayed for a given download in the Downloads window. First you need to overlay

  5. Code snippets JavaScript Debugger Service – Mozilla Developer

    https://developer.mozilla.org/en/Code…/JavaScript_Debugger_Servic
    23 May 2011 – is an XPCOM Component that allows the tracking of JavaScript while it is being executed in the browser. An Overview. Acquiring the Service

  6. Code snippets On page load – Mozilla Developer Network

    https://developer.mozilla.org/en/Code_snippets/On_page_load
    This article is for XUL/JavaScript developers who want to have custom code executed each time a new page is loaded in browser/mail. If you need finer control

  7. Code snippets HTML in XUL for rich tooltips – Mozilla Developer

    https://developer.mozilla.org/en/…/HTML_in_XUL_for_rich_tooltips
    19 Dec 2009 – Dynamic HTML in XUL Tooltip. Insert the appropriate code from below into your XUL overlay. This example is what the final XUL overlay could

  8. Code snippets Windows – Mozilla Developer Network

    https://developer.mozilla.org/en/Code_snippets/Windows
    12 Jul 2011 – Opening new browser windows. To open a new browser window, you can simply use window.open() . However, window.open() returns a

  9. Code snippets HTML to DOM – Mozilla Developer Network

    https://developer.mozilla.org/en/Code_snippets/HTML_to_DOM
    21 Mar 2012 – Using a hidden iframe element to parse HTML to a window’s DOM; 3. Using a hidden XUL iframe (alternate example). Although you can now

  10. Bookmarks – MDN

    https://developer.mozilla.org/en/Code_snippets/Bookmarks
    30 Jan 2009 – Creating a new bookmark. var win = myBrowser.contentWindow; // Get the bookmarks service const BMSVC

  11. Code snippets Sidebar – Mozilla Developer Network

    https://developer.mozilla.org/en/Code_snippets/Sidebar
    26 Jan 2012 – Opening and closing the sidebar. Firefox provides a built-in toggleSidebar() function defined in browser.js . This means that the function is

  12. Miscellaneous – MDN – Mozilla Developer Network

    https://developer.mozilla.org/en/Code_snippets/Miscellaneous
    11 May 2011 – Saving the current web page to a local file. Although the following code does not prompt the user for a filename, you can do so using the file

  13. Code snippets Finding window handles – Mozilla Developer Network

    https://developer.mozilla.org/…/Code_snippets:Finding_Window_Ha
    10 Sep 2010 – Starting in Gecko 2.0 (Firefox 4 / Thunderbird 3.3 / SeaMonkey 2.1) , only the top level browser window has an HWND. Web content windows

  14. Code snippets Finding window handles – Mozilla Developer Network

    https://developer.mozilla.org/en/Code…/Finding_Window_Handles
    10 Sep 2010 – 3. Yet Another way to find a window handle (parent window handle). When working on Windows platforms, many APIs and frameworks require

  15. browser.xul – Mozilla Developer Network

    https://developer.mozilla.org/en/Code_snippets/Tabbed_browser
    12 Jan 2012 – Here you should find a set of useful code snippets to help you work with Firefox’s tabbed browser. The comments normally mark where you

  16. Post data to window – MDN

    https://developer.mozilla.org/en/Code…/Post_data_to_window
    9 Jun 2011 – This offers examples of sending POST data to the server and displaying the server response. Need more elaborate examples, examples of

  17. Code snippets LookupNamespaceURI – Mozilla Developer Network

    https://developer.mozilla.org/En/Code…/LookupNamespaceURI
    23 Sep 2010 – Note that all Gecko-based browsers (including Firefox) support Node.lookupNamespaceURI. This function is not necessary for Gecko-based

  18. Code snippets Cookies – Mozilla Developer Network

    https://developer.mozilla.org/en/Code_snippets/Cookies
    26 Jan 2012 – Reading existing cookies. var ios = Components.classes[“@mozilla.org/network/io-service;1”] .getService(Components.interfaces.nsIIOService)

    You visited this page on 5/6/12.

  19. Canvas – MDN

    https://developer.mozilla.org/en/Code_snippets/Canvas
    29 Nov 2011 – For general information about using <canvas> see the canvas topic page. Chaining methods. Class to give jQuery-style chained access to 2D

  20. Label and description – MDN

    https://developer.mozilla.org/en/Code…/Label_and_description
    10 Oct 2008 – Line breaking. Under normal conditions, a description will not break long-running text and the text may be cropped or hidden. To cause the text

  21. Threads – MDN

    https://developer.mozilla.org/en/Code_snippets/Threads
    20 Feb 2011 – One of the most common questions related to extension development is how to perform long-running operations in the background. If not done

  22. getAttributeNS – MDN

    https://developer.mozilla.org/en/Code_snippets/getAttributeNS
    18 Feb 2009 – As some browsers do not support getAttributeNS, the following might be used to work on them as well. While namespaced attributes are less

  23. Embedding SVG – MDN

    https://developer.mozilla.org/en/Code_snippets/Embedding_SVG
    29 Oct 2008 – Embedding in XHTML. Make sure you use the right namespace when embedding. Notice the template and example use XHTML to handle the

  24. Code snippets Downloading Files – Mozilla Developer Network

    https://developer.mozilla.org/en/Code_snippets/Downloading_Files
    12 Feb 2011 – Downloading files. To download a file, create an instance of nsIWebBrowserPersist and call its nsIWebBrowserPersist.saveURI() method

    You visited this page on 5/6/12.

  25. JS XPCOM – MDN

    https://developer.mozilla.org/en/Code_snippets/JS_XPCOM
    4 Mar 2009 – Interfaces. Every XPCOM object implements one or more interfaces. An interface is simply a list of constants and methods that can be called on

  26. Code snippets Running applications – Mozilla Developer Network

    https://developer.mozilla.org/en/Code…/Running_applications
    14 Jul 2011 – This method has the same effect as if you double-clicked the file, so for executable files—it will just run the file without any parameters. For more

  27. IsDefaultNamespace – MDN

    https://developer.mozilla.org/En/Code_snippets/IsDefaultNamespace
    18 Feb 2009 – quickly return the standard value for Mozilla browsers). // http://www.w3.org/TR/DOM-Level-3-Core/core.html#Node3-isDefaultNamespace

  28. Code snippets Progress Listeners – Mozilla Developer Network

    https://developer.mozilla.org/en/Code_snippets/Progress_Listeners
    22 Feb 2011 – Progress Listeners. Progress listeners allow extensions to be notified of events associated with documents loading in the browser and with tab

  29. Code snippets Dialogs and Prompts – Mozilla Developer Network

    https://developer.mozilla.org/en/Code…/Dialogs_and_Prompts
    8 Nov 2011 – Dialogs in Mozilla. Whenever you want to create a dialog in your application, use <dialog> (instead of usual <window>) as root element in the

  30. Preferences – MDN

    https://developer.mozilla.org/en/Code_snippets/Preferences
    20 Mar 2012 – This article provides examples for extension developers that wish to use the Mozilla preferences system. Information here applies to the Mozilla

  31. Scrollbar – MDN

    https://developer.mozilla.org/en/Code_snippets/Scrollbar
    16 Jun 2010 – This example shows how to style the scrollbars in your xul application. Scrollbars inside browser elements will be styled to. Tested on windows

  32. Code snippets LookupPrefix – Mozilla Developer Network

    https://developer.mozilla.org/En/Code_snippets/LookupPrefix
    15 Apr 2010 – This function is not necessary for Gecko-based browsers when used in XHTML. function lookupPrefix (node, namespaceURI) { var htmlMode

  33. Code snippets QuerySelector – Mozilla Developer Network

    https://developer.mozilla.org/En/Code_snippets/QuerySelector
    23 Dec 2011 – Along the lines of other frameworks such as jQuery or Prototype, shortening the “querySelector” name can be convenient. function $ (selector

  34. Code snippets Toolbar – Mozilla Developer Network

    https://developer.mozilla.org/en/Code_snippets/Toolbar
    1 Feb 2012 – Adding a toolbar button. There are two tutorials available: An elaborate step by step tutorial for beginners: Custom Toolbar Button; A tutorial

  35. Tabbox – MDN

    https://developer.mozilla.org/En/Code_snippets/Tabbox
    3 Aug 2010 – Handling onclosetab Event. Assuming the tabbox, tabs, and tabpanels widgets with id’s the same as their nodeName, this function will correctly

  36. Page Loading – MDN

    https://developer.mozilla.org/en/Code_snippets/Page_Loading
    24 Apr 2007 – Page Loading. On page load: How to execute code each time a new page is loaded in browser/mail. Progress Listeners: Progress listeners

  37. SVG General – MDN

    https://developer.mozilla.org/en/Code_snippets/SVG_General
    26 Mar 2011 – On this page you will find some simple, general information on SVG markup. Hopefully, enough to get you creating some SVG images. You will

  38. XPath – MDN

    https://developer.mozilla.org/En/Code_snippets/XPath
    15 Nov 2008 – Notes and sample code for XPath and Ajax. (The following was moved from document.evaluate) obj.evaluate(xpathExpression,contextNode

  39. Boxes – MDN

    https://developer.mozilla.org/en/Code_snippets/Boxes
    23 Jun 2008 – Wrapping contents. In HTML you can use a DIV as a container and when the DIV changes size, the contents will wrap or adjust the layout.

  40. XML – MDN

    https://developer.mozilla.org/en/Code_snippets/XML
    24 Jun 2008 – How to Create a DOM tree · Using XMLHttpRequest · Parsing and serializing XML · Using XPath · XSL Transforms · XLink · XInclude · xml:id

  41. Autocomplete – MDN

    https://developer.mozilla.org/en/Code_snippets/Autocomplete
    30 Jul 2011 – Turning on autocomplete. First, declare a panel with the “autocomplete” type, like so: <panel id=”popup_autocomplete” type=”autocomplete”

  42. Code snippets URI parsing – Mozilla Developer Network

    https://developer.mozilla.org/en/Code_snippets/URI_parsing
    30 Nov 2009 – Grabbing the main domain using the EffectiveTLDService. Even using the ETLDService, you’re unable to get just the base domain sans TLD.

  43. Code snippets Modules – Mozilla Developer Network

    https://developer.mozilla.org/En/Code_snippets/Modules
    9 Jan 2010 – Some simple code to turn a JavaScript module into non-Mozilla-specific code (e.g., if porting to the browser). The use of eval() will probably not

  44. Interaction between privileged and non – Mozilla Developer Network

    https://developer.mozilla.org/…/Interaction_between_privileged_and
    13 Sep 2011 – Sending data from unprivileged document to chrome. An easy way to send data from a web page to an extension is by using custom DOM

  45. base function – MDN

    https://developer.mozilla.org/en/Code_snippets/xml/base_function
    24 Jun 2008 – These two functions aim to allow some support for xml:base. Note however, that this code is not based on a thorough examination of the specs

  46. Code snippets HTML in XUL for rich tooltips – Mozilla Developer

    https://developer.mozilla.org/…/HTML_in_XUL_for_rich_tooltips?…
    19 Dec 2009 – Dynamic HTML in XUL Tooltip. Insert the appropriate code from below into your XUL overlay. This example is what the final XUL overlay could

  47. Code snippets Windows – Mozilla Developer Network

    https://developer.mozilla.org/en/Code_snippets/Windows?action
    12 Jul 2011 – Opening new browser windows. To open a new browser window, you can simply use window.open() . However, window.open() returns a

  48. Code snippets QuerySelector – Mozilla Developer Network

    https://developer.mozilla.org/En/Code_snippets/QuerySelector?…
    23 Dec 2011 – Along the lines of other frameworks such as jQuery or Prototype, shortening the “querySelector” name can be convenient. function $ (selector

  49. Code snippets Sidebar – Mozilla Developer Network

    https://developer.mozilla.org/en/Code_snippets/Sidebar?action=edit
    26 Jan 2012 – Opening and closing the sidebar. Firefox provides a built-in toggleSidebar() function defined in browser.js . This means that the function is

  50. Code snippets Dialogs and Prompts – Mozilla Developer Network

    https://developer.mozilla.org/en/Code…/Dialogs_and_Prompts?action
    8 Nov 2011 – Dialogs in Mozilla. Whenever you want to create a dialog in your application, use <dialog> (instead of usual <window>) as root element in the

  51. Code snippets Downloading Files – Mozilla Developer Network

    https://developer.mozilla.org/en/Code…/Downloading_Files?action
    12 Feb 2011 – Downloading files. To download a file, create an instance of nsIWebBrowserPersist and call its nsIWebBrowserPersist.saveURI() method

  52. Code snippets Progress Listeners – Mozilla Developer Network

    https://developer.mozilla.org/en/Code_snippets/Progress_Listeners?…
    22 Feb 2011 – Progress Listeners. Progress listeners allow extensions to be notified of events associated with documents loading in the browser and with tab

  53. Code snippets Cookies – Mozilla Developer Network

    https://developer.mozilla.org/en/Code_snippets/Cookies?action=edit
    26 Jan 2012 – Reading existing cookies. var ios = Components.classes[“@mozilla.org/network/io-service;1”] .getService(Components.interfaces.nsIIOService)

  54. Code snippets Customizing the download progress bar

    https://developer.mozilla.org/…/Customizing_the_download_progres
    17 Nov 2009 – This example illustrates how to customize the progress bar displayed for a given download in the Downloads window. First you need to overlay

  55. Miscellaneous – MDN – Mozilla Developer Network

    https://developer.mozilla.org/en/Code_snippets/Miscellaneous?…
    11 May 2011 – Saving the current web page to a local file. Although the following code does not prompt the user for a filename, you can do so using the file

  56. Code snippets HTML to DOM – Mozilla Developer Network

    https://developer.mozilla.org/en/Code_snippets/HTML_to_DOM?…
    22 Feb 2012 – Using a hidden XUL iframe (alternate example). Although you can now natively parse HTML using DOMParser and XMLHttpRequest , this is a

  57. Code snippets JavaScript Debugger Service – Mozilla Developer

    https://developer.mozilla.org/en/…/JavaScript_Debugger_Service?…
    23 May 2011 – reference to undefined name ‘syntax’ Exception of type ‘MindTouch.Deki.Script.Runtime.DekiScriptUndefinedNameException’ was thrown.

  58. Code snippets On page load – Mozilla Developer Network

    https://developer.mozilla.org/en/Code_snippets/On_page_load?…
    This article is for XUL/JavaScript developers who want to have custom code executed each time a new page is loaded in browser/mail. If you need finer control

  59. Code snippets Toolbar – Mozilla Developer Network

    https://developer.mozilla.org/en/Code_snippets/Toolbar?action=edit
    1 Feb 2012 – Adding a toolbar button. There are two tutorials available: An elaborate step by step tutorial for beginners: Custom Toolbar Button; A tutorial

  60. Code snippets Tree – Mozilla Developer Network

    https://developer.mozilla.org/en/Code_snippets/Tree?action=edit
    2 Jul 2010 – Expanding/Collapsing all tree nodes. To expand all tree nodes: var treeView = tree.treeBoxObject.view; for (var i = 0; i < treeView.rowCount

  61. Code snippets LookupPrefix – Mozilla Developer Network

    https://developer.mozilla.org/En/Code_snippets/LookupPrefix?…
    15 Apr 2010 – This function is not necessary for Gecko-based browsers when used in XHTML. function lookupPrefix (node, namespaceURI) { var htmlMode

  62. browser.xul – Mozilla Developer Network

    https://developer.mozilla.org/en/Code_snippets/Tabbed_browser?…
    12 Jan 2012 – Here you should find a set of useful code snippets to help you work with Firefox’s tabbed browser. The comments normally mark where you

  63. Code snippets Finding window handles – Mozilla Developer Network

    https://developer.mozilla.org/en/Code…/Finding_Window_Handles?…
    10 Sep 2010 – 3. Yet Another way to find a window handle (parent window handle). When working on Windows platforms, many APIs and frameworks require

  64. Code snippets LookupNamespaceURI – Mozilla Developer Network

    https://developer.mozilla.org/En/Code…/LookupNamespaceURI?…
    23 Sep 2010 – Note that all Gecko-based browsers (including Firefox) support Node.lookupNamespaceURI. This function is not necessary for Gecko-based

  65. Code snippets Alerts and Notifications – Mozilla Developer Network

    https://developer.mozilla.org/en/Code…/Alerts_and_Notifications?…
    16 Sep 2010 – Pop-ups. notify.png. The following code presents a non-modal pop-up, which automatically disappears after an appropriate delay. It uses

  66. Code snippets Running applications – Mozilla Developer Network

    https://developer.mozilla.org/en/Code…/Running_applications?action
    14 Jul 2011 – This method has the same effect as if you double-clicked the file, so for executable files—it will just run the file without any parameters. For more

  67. Code snippets Modules – Mozilla Developer Network

    https://developer.mozilla.org/En/Code_snippets/Modules?action
    9 Jan 2010 – Some simple code to turn a JavaScript module into non-Mozilla-specific code (e.g., if porting to the browser). The use of eval() will probably not

  68. Code snippets URI parsing – Mozilla Developer Network

    https://developer.mozilla.org/en/Code_snippets/URI_parsing?action
    30 Nov 2009 – Grabbing the main domain using the EffectiveTLDService. Even using the ETLDService, you’re unable to get just the base domain sans TLD.

  69. Code snippets File I/O – Mozilla Developer Network

    https://developer.mozilla.org/en/Code_snippets/File_I%2F%2FO
    31 Mar 2012 – Available libraries. There are a few JavaScript wrappers for I/O XPCOM components. See JSLib and io.js (original by MonkeeSage). The io.js

    You visited this page on 5/6/12.

  70. Interaction between privileged and non – Mozilla Developer Network

    https://developer.mozilla.org/…/Interaction_between_privileged_and
    13 Sep 2011 – Sending data from unprivileged document to chrome. An easy way to send data from a web page to an extension is by using custom DOM

  71. Code snippets File I/O – Mozilla Developer Network

    https://developer.mozilla.org/en/Code_snippets/File_I%2F%2FO?…
    4 Sep 2011 – Available libraries. There are a few JavaScript wrappers for I/O XPCOM components. See JSLib and io.js (original by MonkeeSage). The io.js

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: