I have two functions in Javascript:
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;
}
These appear to set the height and width of the document window, based on the size of the window? I could be wrong here....
What I have done is embeded a toolbar above this document, this toolbar can be hidden or shown at various points.
I need the above function to be called when I use the following jQuery,
$("#Main").animate({top: "89px"}, 200);
Any assistance greatly appreciated!
asked Jun 7, 2010 at 14:20
CLiown
13.9k51 gold badges129 silver badges206 bronze badges
-
2The two functions you posted don't have any effect, they just get some values, calling them wouldn't have any effect unless you're feeding the result to something else.Nick Craver– Nick Craver2010年06月07日 14:21:50 +00:00Commented Jun 7, 2010 at 14:21
-
Your right, more info required to answer this questions. Above function 'gets' the values required to set height & width but need to find function that sets the height & width first.CLiown– CLiown2010年06月07日 14:49:40 +00:00Commented Jun 7, 2010 at 14:49
1 Answer 1
animate() takes a callback function.
$("#Main").animate({top: "89px"}, 200, function() {
getWindowWidth();
getWindowHeight(); });
answered Jun 7, 2010 at 14:22
Sean Vieira
161k34 gold badges321 silver badges297 bronze badges
Sign up to request clarification or add additional context in comments.
1 Comment
Nick Craver
Which this is correct, it doesn't really address the problem, look at the functions...what are you doing with their return values? Currently this is just wasting CPU cycles at the animation...
lang-js