Document: phương thức queryCommandSupported()
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.
Non-standard: This feature is not standardized. We do not recommend using non-standard features in production, as they have limited browser support, and may change or be removed. However, they can be a suitable alternative in specific cases where no standard option exists.
Note:
Mặc dù phương thức execCommand() đã lỗi thời, nếu bạn quyết định sử dụng nó vì những lý do được nêu trên trang đó, bạn nên cân nhắc kiểm tra khả năng sẵn có của lệnh bằng cách sử dụng queryCommandSupported() để đảm bảo tương thích.
Phương thức Document.queryCommandSupported() báo cáo liệu lệnh trình soạn thảo đã chỉ định có được trình duyệt hỗ trợ hay không.
Cú pháp
queryCommandSupported(command)
Tham số
command-
Lệnh cần xác định hỗ trợ.
Giá trị trả về
Trả về một giá trị boolean là true nếu lệnh được hỗ trợ và false nếu lệnh không được hỗ trợ.
Ghi chú
Lệnh 'paste' trả về false không chỉ khi tính năng không khả dụng, mà còn nếu tập lệnh gọi nó không có đủ quyền để thực hiện hành động.
Ví dụ
const flg = document.queryCommandSupported("SelectAll");
if (flg) {
// Thực hiện điều gì đó…
}
Đặc tả kỹ thuật
Tính năng này không thuộc bất kỳ đặc tả kỹ thuật hiện tại nào. Nó không còn nằm trong lộ trình trở thành tiêu chuẩn. Có một bản nháp đặc tả W3C execCommand không chính thức.