By shenagarg on
Generally in a webpage we add javascript on page when all contents are loaded by adding the line
$(window).load(function(){ /*code here*/ })
I am wondering how we can add this kind of code in drupal. Any suggestions please?
Comments
You can use drupal_add_us
You can use drupal_add_us function to do so (in a custom module).
But it's also possible to add the js file in theme's .info file and from template.php.
What are you trying to do exactly? Should it present in all pages?
What's new and changing in PHP 8.4
Thanks for reply
I have a very small javascript code running on jquery. Just 2-3 lines say. I have to add it to one specific page only not on all pages.
On one website I have to include a code before document is loaded so I pasted following code in a block on that page only:
And it worked fine. But this adds code before page is loaded. Here I want to have it after page content is loaded. any suggestions on that?
There is no function drupal_add_us I guess you are saying about drupal_add_js()
I was wondering if I can add some code in block of that page itself.
Thanks