DOMRectReadOnly: hàm khởi tạo DOMRectReadOnly()

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since January 2020.

Note: This feature is available in Web Workers.

Hàm khởi tạo DOMRectReadOnly() tạo một đối tượng DOMRectReadOnly mới.

Cú pháp

js
new DOMRectReadOnly(x, y, width, height)

Tham số

x

Tọa độ x của gốc tọa độ DOMRectReadOnly.

y

Tọa độ y của gốc tọa độ DOMRectReadOnly.

width

Chiều rộng của DOMRectReadOnly.

height

Chiều cao của DOMRectReadOnly.

Ví dụ

Để tạo một DOMRectReadOnly mới, bạn có thể chạy dòng mã như sau:

js
const myDOMRect = new DOMRectReadOnly(0, 0, 100, 100);
// Chạy 'myDOMRect' trong bảng điều khiển sẽ trả về
// DOMRectReadOnly { x: 0, y: 0, width: 100, height: 100, top: 0, right: 100, bottom: 100, left: 0 }

Thông số kỹ thuật

Specification
Geometry Interfaces Module Level 1
# dom-domrectreadonly-domrectreadonly

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

Xem thêm