在Drupal中为OnLoad添加一个函数 [英] Add a function to OnLoad in Drupal
问题描述
我在我的一个皮肤/主题的左侧栏中有一个HTML /文本默认模块。我有一些Javascript在那里我试图将今天的日期设置为我的JavaScript日期下拉列表。我不能使用'body.onLoad',因为Drupal阻止它不知何故?
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?
我发现一个解决方案,我可以在这里添加我的javascript功能:
if (isJsEnabled()){
addLoadEvent(yourCustomJSFunction);
}
I found a solution saying I can add my javascript function here: if (isJsEnabled()) { addLoadEvent(yourCustomJSFunction); }
如果我只是使用默认的HTML /文本模块,我该如何添加?
How can I add that if I'm just using a default HTML/text module?
谢谢!
推荐答案
Drupal使用 jQuery JavaScript库。您写的使用Drupal的任何JavaScript都应该理想地使用jQuery。查看api上的 JavaScript启动指南 .drupal.org的一些基础知识,特别是 Drupal.behaviors
部分。
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.
这篇关于在Drupal中为OnLoad添加一个函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!