Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By Suvv on
I need to use the unload and load events in the body tag.
Is there a suitable hook to enable me to do this?
eg., I want this ...
Comments
Things are handled a little
Things are handled a little differently in Drupal, as many modules may need to do things onload. Instead of piling them all in an onload attribute, we use jQuery's $(document).ready() function:
This has the added benefit of running before onload would, as onload waits for images etc. to load - if you have a lot, it could take forever to run. It can be added to the page by a module using something like drupal_add_js() or drupal_set_html_head().