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 lower = name.toLowerCase();
8 // innerHeight and innerWidth
9 jQuery.fn["inner" + name] = function(){
11 jQuery.css( this[0], lower, false, "padding" ) :
15 // outerHeight and outerWidth
16 jQuery.fn["outer" + name] = function(margin) {
18 jQuery.css( this[0], lower, false, margin ? "margin" : "border" ) :
22 var type = name.toLowerCase();
24 jQuery.fn[ type ] = function( size ) {
25 // Get window width or height
26 return this[0] == window ?
27 // Everyone else use document.documentElement or document.body depending on Quirks vs Standards mode
28 document.compatMode == "CSS1Compat" && document.documentElement[ "client" + name ] ||
29 document.body[ "client" + name ] :
31 // Get document width or height
33 // Either scroll[Width/Height] or offset[Width/Height], whichever is greater
35 document.documentElement["client" + name],
36 document.body["scroll" + name], document.documentElement["scroll" + name],
37 document.body["offset" + name], document.documentElement["offset" + name]
40 // Get or set width or height on the element
42 // Get width or height on the element
43 (this.length ? jQuery.css( this[0], type ) : null) :
45 // Set the width or height on the element (default to pixels if value is unitless)
46 this.css( type, typeof size === "string" ? size : size + "px" );