这是 实验性技术
检查 浏览器兼容性表格 要小心谨慎在生产中使用这之前。

ScreenOrientation 接口的 Screen Orientation API provides information about the current orientation of the document.

特性

ScreenOrientation.type 只读

Returns the document's current orientation type, one of "portrait-primary", "portrait-secondary", "landscape-primary", or "landscape-secondary".

ScreenOrientation.angle 只读

Returns the document's current orientation angle.

事件处理程序

ScreenOrientation.onchange
EventHandler called whenever the screen changes orientation.

方法

ScreenOrientation.lock()
Locks the orientation of the containing document to its default orientation and returns a Promise .
ScreenOrientation.unlock()

Unlocks the orientation of the containing document from its default orientation.

规范

规范 状态 注释
Screen Orientation API
The definition of 'ScreenOrientation' in that specification.
工作草案 初始定义。

浏览器兼容性

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. 更新 GitHub 上的兼容性数据
桌面 移动
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
ScreenOrientation Chrome 38 Edge 79 Firefox 43 IE No Opera 25 Safari No WebView Android 38 Chrome Android 38 Firefox Android 43 Opera Android 25 Safari iOS No Samsung Internet Android 3.0
angle Chrome 38 Edge 79 Firefox 43 IE No Opera 25 Safari No WebView Android 38 Chrome Android 38 Firefox Android 43 Opera Android 25 Safari iOS No Samsung Internet Android 3.0
lock Chrome 38 Edge 79 Firefox 43 IE No Opera 25 Safari No WebView Android 38 Chrome Android 38 Firefox Android 43 Opera Android 25 Safari iOS No Samsung Internet Android 3.0
onchange Chrome 38 Edge 79 Firefox 43 IE No Opera 25 Safari No WebView Android 38 Chrome Android 38 Firefox Android 43 Opera Android 25 Safari iOS No Samsung Internet Android 3.0
type Chrome 38 Edge 79 Firefox 43 IE No Opera 25 Safari No WebView Android 38 Chrome Android 38 Firefox Android 43 Opera Android 25 Safari iOS No Samsung Internet Android 3.0
unlock Chrome 38 Edge 79 Firefox 43 IE No Opera 25 Safari No WebView Android 38 Chrome Android 38 Firefox Android 43 Opera Android 25 Safari iOS No Samsung Internet Android 3.0

图例

完整支持

完整支持

不支持

不支持

元数据

  • 最后修改:
  1. ScreenOrientation
  2. 特性
    1. angle
    2. lock()
    3. onchange
    4. type
    5. unlock()
  3. Related pages for Screen Orientation API
    1. Screen.orientation