Window.innerWidth


๋ธŒ๋ผ์šฐ์ € ์œˆ๋„์šฐ์˜ ๋ทฐํฌํŠธ ๋„ˆ๋น„๋กœ, ์ˆ˜์ง ์Šคํฌ๋กค๋ฐ”๊ฐ€ ์กด์žฌํ•œ๋‹ค๋ฉด ํฌํ•จํ•ฉ๋‹ˆ๋‹ค.

๊ตฌ๋ฌธ

 

var intViewportWidth = window.innerWidth;

Value

intViewportWidth stores the window.innerWidth property value.

The window.innerWidth property is read only; it has no default value.

์ฐธ๊ณ 

innerWidth ๊ฐ’์€ window, frame, frameset์ด๋‚˜ ๋‹ค๋ฅธ ์œˆ๋„์šฐ๋“ค์ฒ˜๋Ÿผ ๋ชจ๋“  window ํ˜•์‹์˜ ๊ฐ์ฒด์—์„œ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

There is an algorithm to obtain the width of the viewport excluding, if rendered, the vertical scrollbar.

์˜ˆ์ œ

// ๋‹ค์Œ๊ณผ ๊ฐ™์ด ๋ทฐํฌํŠธ์˜ ํญ์„ ๋ฐ›์•„์˜ฌ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
var intFrameWidth = window.innerWidth;

// ๋‹ค์Œ๊ณผ ๊ฐ™์ด frameset ์•ˆ์˜ ์–ด๋–ค frame์˜ ๋ทฐํฌํŠธ ํญ์„ ๋ฐ›์•„์˜ฌ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
var intFrameWidth = self.innerWidth;

// ๋‹ค์Œ๊ณผ ๊ฐ™์ด ๊ฐ€์žฅ ๊ฐ€๊นŒ์šด frameset์˜ ๋ทฐํฌํŠธ ํญ์„ ๋ฐ›์•„์˜ฌ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
var intFramesetWidth = parent.innerWidth;

// ๋‹ค์Œ๊ณผ ๊ฐ™์ด ๊ฐ€์žฅ ๋ฐ”๊นฅ์ชฝ ํ”„๋ ˆ์ž„์…‹์˜ ๋ทฐํฌํŠธ ํญ์„ ๋ฐ›์•„์˜ฌ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
var intOuterFramesetWidth = top.innerWidth;

์œˆ๋„์šฐ์˜ ์‚ฌ์ด์ฆˆ๋ฅผ ๋ณ€๊ฒฝํ•˜๋ ค๋ฉด, window.resizeBy ๋˜๋Š” window.resizeTo๋ฅผ ์ฐธ์กฐํ•˜์„ธ์š”.

๋ช…์„ธ

 

Specification Status Comment
CSS Object Model (CSSOM) View Module
The definition of 'window.innerWidth' in that specification.
Working Draft Initial definition

๋ธŒ๋ผ์šฐ์ € ํ˜ธํ™˜์„ฑ

BCD tables only load in the browser

์ฐธ๊ณ  ์ž๋ฃŒ