2010-06-07 63 views
0

我有两个功能在Javascript:调用JavaScript函数使用jQuery

function getWindowWidth(){ 
var x = 0; 
if (self.innerHeight){ 
x = self.innerWidth; 
}else if (document.documentElement && document.documentElement.clientHeight){ 
x = document.documentElement.clientWidth; 
}else if (document.body){ 
x = document.body.clientWidth; 
}return x; 
}function getWindowHeight(){ 
var y = 0; 
if (self.innerHeight){ 
y = self.innerHeight; 
}else if (document.documentElement && document.documentElement.clientHeight){ 
y = document.documentElement.clientHeight; 
}else if (document.body){ 
y = document.body.clientHeight; 
} 

这些似乎设置文档窗口的高度和宽度,根据窗口的大小?我可能在这里是错的......

我所做的是在本文件上面嵌入一个工具栏,这个工具栏可以隐藏或显示在不同的点上。

我需要以上功能时,我用下面的jQuery来调用,

$("#Main").animate({top: "89px"}, 200); 

任何援助不胜感激!

+2

你发布的两个函数没有任何作用,他们只是得到一些值,调用它们将不会有任何效果,除非你将结果提供给其他东西。 – 2010-06-07 14:21:50

+0

您的权利,需要更多信息来回答这个问题。上面的函数'获取'设置高度和宽度所需的值,但需要先找到设置高度和宽度的函数。 – CLiown 2010-06-07 14:49:40

回答

2

animate()需要回调函数。

$("#Main").animate({top: "89px"}, 200, function() { 
    getWindowWidth(); 
    getWindowHeight(); }); 
+0

这是正确的,它没有真正解决问题,查看功能......你在做什么,他们的返回值?目前这只是在动画中浪费CPU周期...... – 2010-06-07 14:28:57