Is there a location where I can drop in a custom JavaScript file in Drupal 7.x?
It just includes simple event actions for menus, and I don't want to edit the theme/module files.
Or do I have to just add the "include" hook to the theme/module?
There's three places where you can put your Javascript resources:
Mechaflash. In order to make the theme folder "more organized", generally people create a dedicated js folder. I would place Javascript in the theme when your Javascript delivers functionality specific to the theme / presentation layer, or that it affects all of the site (global). js folder can also apply here. I generally put JS on the modules when the Javascript is delivering a very specialized functionality relevant to a specific module. It also allows you to "package" your Javascript with your modules and to pass this modules to other sites (i.e. a modular approach).You can do all of this using the drupal_add_js() function. Here are some examples of how to add a JS file from a module:
// Add a "javascript library" from your module. JS_LIBRARY is an integer constant with a value of -100, which means that `mecha_library.js` will be added before `mecha_ninja.js`.
$module_path = drupal_get_path('module', 'my_module');
drupal_add_js($module_path. 'js/mecha_library.js', array('group' => JS_LIBRARY));
// Add a javascript file from your module. The default 'group' here is JS_DEFAULT, so mecha_ninja.js will be added after mecha_library.js.
$path = drupal_get_path('module', 'my_module');
drupal_add_js($path. 'js/mecha_ninja.js', 'file');
.info file hence modify your theme. Also theses changes will be deleted on each theme update so you'd rather consider a sub-theme.
Drupal 7 allows scripts[] and stylesheets[] in both theme.info and module.info files.
The easiest way is in your theme .info file.
You just need to add scripts[] = myscript.js in to the .info file of the theme you are using.