Document: thuộc tính fullscreen

Deprecated: This feature is no longer recommended. Though some browsers might still support it, it may have already been removed from the relevant web standards, may be in the process of being dropped, or may only be kept for compatibility purposes. Avoid using it, and update existing code if possible; see the compatibility table at the bottom of this page to guide your decision. Be aware that this feature may cease to work at any time.

Thuộc tính chỉ đọc fullscreen đã lỗi thời của giao diện Document báo cáo liệu tài liệu có đang hiển thị nội dung ở chế độ toàn màn hình hay không.

Mặc dù thuộc tính này là chỉ đọc, nó sẽ không ném lỗi nếu bị sửa đổi (ngay cả trong strict mode); setter là một thao tác rỗng và sẽ bị bỏ qua.

Note: Vì thuộc tính này đã lỗi thời, bạn có thể xác định xem chế độ toàn màn hình có đang hoạt động trên tài liệu hay không bằng cách kiểm tra xem Document.fullscreenElement có khác null không.

Giá trị

Một giá trị Boolean là true nếu tài liệu đang hiển thị một phần tử ở chế độ toàn màn hình; ngược lại, giá trị là false.

Ví dụ

Hàm đơn giản này báo cáo xem chế độ toàn màn hình có đang hoạt động hay không, sử dụng thuộc tính fullscreen đã lỗi thời.

js
function isDocumentInFullScreenMode() {
  return document.fullscreen;
}

Ví dụ tiếp theo, mặt khác, sử dụng thuộc tính fullscreenElement hiện tại để xác định điều tương tự:

js
function isDocumentInFullScreenMode() {
  return document.fullscreenElement !== null;
}

Nếu fullscreenElement không phải là null, điều này trả về true, cho biết chế độ toàn màn hình đang hoạt động.

Đặc tả kỹ thuật

Specification
Fullscreen API
# dom-document-fullscreen

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

Xem thêm