1 // Create innerHeight, innerWidth, outerHeight and outerWidth methods
2 jQuery.each([ "Height", "Width" ], function(i, name){
4 var tl = i ? "Left" : "Top", // top or left
5 br = i ? "Right" : "Bottom", // bottom or right
6 type = name.toLowerCase();
8 // innerHeight and innerWidth
9 jQuery.fn["inner" + name] = function(){
11 jQuery.css( this[0], type, false, "padding" ) :
15 // outerHeight and outerWidth
16 jQuery.fn["outer" + name] = function(margin) {
18 jQuery.css( this[0], type, false, margin ? "margin" : "border" ) :
22 jQuery.fn[ type ] = function( size ) {
23 // Get window width or height
24 return this[0] == window ?
25 // Everyone else use document.documentElement or document.body depending on Quirks vs Standards mode
26 document.compatMode == "CSS1Compat" && document.documentElement[ "client" + name ] ||
27 document.body[ "client" + name ] :
29 // Get document width or height
31 // Either scroll[Width/Height] or offset[Width/Height], whichever is greater
33 document.documentElement["client" + name],
34 document.body["scroll" + name], document.documentElement["scroll" + name],
35 document.body["offset" + name], document.documentElement["offset" + name]
38 // Get or set width or height on the element
40 // Get width or height on the element
41 (this.length ? jQuery.css( this[0], type ) : null) :
43 // Set the width or height on the element (default to pixels if value is unitless)
44 this.css( type, typeof size === "string" ? size : size + "px" );