Description
outerwidth()
documentation currently states:
This method is not applicable to
window
anddocument
objects; for these, use.width()
instead.
But the jQuery 3.0 migration guide states:
Breaking change:
.outerWidth()
or.outerHeight()
onwindow
includes scrollbar width/heightCalls to
$(window).width()
return the "content width" which excludes any scrollbars that the browser has added if the content exceeds the height of the element. This is different from the width that CSS uses for media queries, which includes the width of the scrollbars. In order to provide a measure that is equivalent to the CSS media query concept of width, the$(window).outerWidth()
method now returns the width including scrollbar width. This is equivalent to the DOM propertywindow.innerWidth
. The same applies for.outerHeight()
.
So it seems to me either the API documentation is obsolete about outerWidth()
not being applicable to window
, or the migration guide is wrong telling us to call outerWidth()
on window to get its "CSS width". This is confusing.
There is the same trouble with .outerHeight()
documentation.