How do I add JavaScript to a page? I made a module, and I want to add a JavaScript file to that module; I enable the module and obvious it works, but I didn't see the JavaScript file that module should take with.

I just put code similar to the following in hook_menu():

function my2form_menu() {
      drupal_add_js(drupal_get_path('module', 'my2form') . '/abc.js');
}


Is it OK?
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