1 // Create innerHeight, innerWidth, outerHeight and outerWidth methods
2 jQuery.each([ "Height", "Width" ], function(i, name){
4 var type = name.toLowerCase();
6 // innerHeight and innerWidth
7 jQuery.fn["inner" + name] = function(){
9 jQuery.css( this[0], type, false, "padding" ) :
13 // outerHeight and outerWidth
14 jQuery.fn["outer" + name] = function(margin) {
16 jQuery.css( this[0], type, false, margin ? "margin" : "border" ) :
20 jQuery.fn[ type ] = function( size ) {
21 // Get window width or height
24 return size == null ? null : this;
27 return ("scrollTo" in elem && elem.document) ? // does it walk and quack like a window?
28 // Everyone else use document.documentElement or document.body depending on Quirks vs Standards mode
29 elem.document.compatMode === "CSS1Compat" && elem.document.documentElement[ "client" + name ] ||
30 elem.document.body[ "client" + name ] :
32 // Get document width or height
33 (elem.nodeType === 9) ? // is it a document
34 // Either scroll[Width/Height] or offset[Width/Height], whichever is greater
36 elem.documentElement["client" + name],
37 elem.body["scroll" + name], elem.documentElement["scroll" + name],
38 elem.body["offset" + name], elem.documentElement["offset" + name]
41 // Get or set width or height on the element
43 // Get width or height on the element
44 jQuery.css( elem, type ) :
46 // Set the width or height on the element (default to pixels if value is unitless)
47 this.css( type, typeof size === "string" ? size : size + "px" );