orientationchange
orientationchange事件在设备的纵横方向改变时触发。
| Bubbles | No |
|---|---|
| Cancelable | No |
| Interface | Event |
| Event handler |
onorientationchange
|
示例
你可以在addEventListener 方法中使用 orientationchange 事件:
js
window.addEventListener("orientationchange", function () {
console.log(
"the orientation of the device is now " + screen.orientation.angle,
);
});
或者使用 onorientationchange 事件处理程序属性:
js
window.onorientationchange = function () {
console.log(
"the orientation of the device is now " + screen.orientation.angle,
);
};
规范
| Specification |
|---|
| Compatibility> # event-orientationchange> |
浏览器兼容性
Loading…