By shane
2011-06-06 13:21

Adding Javascript to a Drupal 6 Module is a pretty simple process. This post can serve as a very simple primer to get you started.

It starts with implementing hook_init() in your .module file.

 * Implements hook_init().
function MYMODULE_init() {
  drupal_add_js(drupal_get_path('module', 'MYMODULE') .'/MYMODULE.js');

Then you will need to create a Javascript file called MYMODULE.js in your module folder. Drupal by default comes with the JQuery library. Your Javascript file should look similar to the one below:

Subscribe to Javascript