Last updated April 20, 2011. Created by katbailey on February 23, 2007.
Edited by jhodgdon, lut4rp, LeeHunter, Wolfflow. Log in to edit this page.
Drupal provides methods for implementing JavaScript. Using these methods will help to keep your code clean and to ensure compatibility with the way other modules implement JavaScript.
A couple of simple principles guide Drupal's JavaScript approach:
- All pages should be perfectly functional without scripts. JavaScript provides alternatives or supplements - not replacements - for standard elements.
- No JavaScript is hard-coded into pages. Rather, actions are attached dynamically to page elements--and only if the needed Javascript support is present.
See also the JavaScript developer API in the API section of the handbook.
Note: this section is currently being overhauled. The numbered subsections are the new content added to date - more to come very soon! The non-numbered subsections are old content that needs to be incorporated, updated or removed.