I need to include jquery-1.10.2 for a module I am building in Drupal 7. The problem is, if I include the file with drupal_add_js in the module's .inc file, it causes the admin menu to display strange (there is no space reserved for it on the screen, so it is usually covered) I've gotten around this by calling drupal_add_js right inside the page callback function for the pages that need jquery. When I do this, the admin menu works fine, but if you click on any items shown in the overlay, the first time you click, there is a javascript error saying:

Uncaught TypeError: Cannot read property 'msie' of undefined

If you click the same button a second time, the overlay will load, but I need to fix this so that there aren't any bugs. I've done some research and it looks like this is because $.browser is depreciated as of 1.9.

So I was wondering if there is a way to include jS but to only have it applied to a specific function or maybe only to the 'content' div of the page? I did find hook_init which supposedly runs whatever commands are inside the function as the pages for that specific module are loaded, however it still seems to apply the include to all pages of my Drupal install.

  • JavaScript scripts are added to the page being rendered; there isn't a way to add them to the function currently executed. You could add the <script> tag inside a <div>, but the global variables of the script are still global; therefore $ would be global too, and override the previously defined function.
    – apaderno
    Commented May 23, 2014 at 15:42

1 Answer 1


The issue is that the admin is trying to load two different versions of jQuery and causing conflicts. The latest version of jQuery Update 7.x-2.4 allows you to control the back and front end versions of jQuery. This may still cause problems with using the overlay but for the most part seems to fix the issue. If you are still having issues you will need to look into a solution on loading two different versions of jQuery, outlined here or disabling the overlay module.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.