How do I add JavaScript to a page?
Adding a call to drupal_add_js() directly in hook_menu() doesn't work; the call to drupal_add_js() should be added on the code that is executed when Drupal is outputting a page. This means:


in the implementation of hook_init()
in an implementation of hook_form_alter(), hook_form_FORM_ID_alter(), or hook_form_BASE_FORM_ID_alter()
in the menu callback for the menu defined from the module


Within a form, Drupal 7 modules can use something similar to the following code, to add a JavaScript file to the currently output page.

$form['#attached']['js'] = array(
  drupal_get_path('module', 'my2form') . '/abc.js',
);


As alternative, if you write the following line in the .info file of a module, the JavaScript file will be added to any page. 

scripts[] = abc.js


The path needs to be relative to the directory containing the module; if the file is contained in a sub-directory of that directory, e.g. javascript, the line should be the following one.

scripts[] = javascript/abc.js