Screen: sự kiện change

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

Experimental: This is an experimental technology
Check the Browser compatibility table carefully before using this in production.

Secure context: This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.

Sự kiện change của giao diện Screen được kích hoạt trên một màn hình cụ thể khi một hoặc nhiều thuộc tính sau thay đổi trên đó:

Cú pháp

Sử dụng tên sự kiện trong các phương thức như addEventListener(), hoặc đặt thuộc tính xử lý sự kiện.

js
addEventListener("change", (event) => { })

onchange = (event) => { }

Kiểu sự kiện

Một Event chung.

Ví dụ

js
const firstScreen = (await window.getScreenDetails()).screens[0];
firstScreen.addEventListener("change", (event) => {
  console.log("Màn hình đầu tiên đã thay đổi.", event, firstScreen);
});

Đặc tả kỹ thuật

Specification
Window Management
# api-screen-onchange-attribute

Tương thích trình duyệt

Xem thêm