我想将.js文件添加到我的网站,并将其显示在<head>
为此,我在主题的template.php文件中添加了以下内容:
function mytheme_preprocess_page(&$variables) {
drupal_add_js(drupal_get_path('theme', 'mytheme') . '/myfile.js', array(
'type' => 'file',
'group' => JS_THEME,
'scope' => 'header',
));
}
但是当我检查源代码时什么也没出现(请注意.js文件在主题根目录中)。
我也尝试过
drupal_add_js('jQuery(document).ready(function () { console.log("Hello!"); });', 'inline');
但一无所获。
有人会知道为什么会这样吗?我能做什么?