topical media & game development
#javascript-code-20-viewport.js / js
// Find the height of the viewport
function windowHeight() {
// A shortcut, in case we’re using Internet Explorer 6 in Strict Mode
var de = document.documentElement;
// If the innerHeight of the browser is available, use that
return self.innerHeight ||
// Otherwise, try to get the height off of the root node
( de && de.clientHeight ) ||
// Finally, try to get the height off of the body element
document.body.clientHeight;
}
// Find the width of the viewport
function windowWidth() {
// A shortcut, in case we’re using Internet Explorer 6 in Strict Mode
var de = document.documentElement;
// If the innerWidth of the browser is available, use that
return self.innerWidth ||
// Otherwise, try to get the width off of the root node
( de && de.clientWidth ) ||
// Finally, try to get the width off of the body element
document.body.clientWidth;
}
(C) Æliens
20/2/2008
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.