Add a function to OnLoad in Drupal

2019-05-23 00:14发布

I have a HTML/text default module in the left bar of one of my skins/themes. I have some Javascript in there I'm trying to set today date to my javascript date dropdowns. I am unable to use 'body.onLoad' because Drupal is blocking it somehow?

I found a solution saying I can add my javascript function here: if (isJsEnabled()) { addLoadEvent(yourCustomJSFunction); }

How can I add that if I'm just using a default HTML/text module?

Thanks!

1条回答
Juvenile、少年°
2楼-- · 2019-05-23 00:52

Drupal uses the jQuery JavaScript library. Any JavaScript you write to work with Drupal should ideally use jQuery as well. Check out the JavaScript Startup Guide on api.drupal.org for some basics, particularly the Drupal.behaviors section.

查看更多
登录 后发表回答