Screen.orientation
Baseline 2023Newly available
Since March 2023, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.
Please help us by answering a few questions.
Experimental: 이 기능은 실험적인 기능입니다.
프로덕션 환경에서 사용하기 전에 브라우저 호환성 표를 주의 깊게 확인하세요.
Summary
orientation
속성은 화면의 현재 방향을 알려 준다.
참고 : 이 함수는 설치된 웹앱 또는 full-screen mode 의 웹페이지에서 동작한다.
Syntax
js
var orientation = window.screen.orientation;
Return value
리턴값은 화면의 방향을 표현하는 문자열이다. portrait-primary, portrait-secondary, landscape-primary, landscape-secondary 가 될 수 있다. (각 값들에 대해 좀 더 많은 정보를 구하려면 lockOrientation
를 보라.).
Example
js
var orientation = screen.mozOrientation;
if (orientation === "landscape-primary") {
console.log("That looks good.");
} else if (orientation === "landscape-secondary") {
console.log("Mmmh... the screen is upside down!");
} else if (
orientation === "portrait-secondary" ||
orientation === "portrait-secondary"
) {
console.log("Mmmh... you should rotate your device");
}
명세서
Specification |
---|
Screen Orientation # dom-screen-orientation |
브라우저 호환성
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
orientation |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
- Requires a vendor prefix or different name for use.
- Has more compatibility info.
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.