我想在我的站点中添加一个.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');
但什么都没有。
有人知道为什么会这样吗?我能做什么?