Environment: Drupal 6.12
Problem:
I am trying to add a box showing only when mouse is over a link using CSS (:hover) and JavaScript (for IE6 Compatibility). But I don't want to add JavaScript to every page using this box. Are there any modules adding a piece of JavaScript to all the Drupal pages?

Comments

WorldFallz’s picture

You can use the drupal_add_js() function in the template.php file for your theme.

xjessie007’s picture

It might not be the best option, but I do this by inserting my custom code into /misc/drupal.js. No additional modules are needed. If you can remember about your code when upgrading the core, this works just fine.

bfr’s picture

Just for reference to the people who still come to this page from google. Please, do NOT add anything to core .js files!

If you are still on Drupal 6 like the original author, use hook_init() with drupal_add_js(). The documentation example adds css but js works in similar manner:

With Drupal 7, you can also add this to your modules .info file to get it to load on every request:
scripts[] = yourscript.js