【发布时间】:2013-12-11 19:02:46
【问题描述】:
我正在尝试在 drupal 7 中调整页面加载和窗口大小时调整几个 div 的大小。
主题信息
name = Theme
description = The Theme
core = 7.x
stylesheets[all][] = css/style.css
scripts[] = js/scripts.js
(the rest)
scripts.js
$(window).load(function() {
getViewport();
});
$(window).resize(function() {
getViewport();
});
function getViewport() {
alert('function hit');
var viewportwidth;
var viewportheight;
if (typeof window.innerWidth != 'undefined')
{
viewportwidth = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
viewportheight = window.innerHeight || document.documentElement.clientHeight || document.body.clientWidth;
}
document.getElementById("content").style.height = (window.innerHeight - 150) + 'px';
document.getElementById('sidebar-first').style.height = (window.innerHeight - 50) + 'px';
}
但既不加载,也不调整大小,或函数或被击中。我确定这是我在 drupal 中使用它的无知,但我似乎找不到答案。
我什至尝试在信息文件中包含我自己的 jquery 库,但无济于事。
谢谢
【问题讨论】:
-
控制台有错误吗?是否加载了jquery?等等……
-
我不确定如何检查。 Drupal 菜鸟,对不起。
-
在浏览器中,按F12打开控制台,看看有没有错误提示
-
TypeError: $ 不是函数 $(window).load(function() {
-
表示未加载 jquery。您必须包含它,但恐怕我不是 drupal 用户。我猜,你的 jquery 路径不准确
标签: javascript jquery drupal drupal-7