WebGLContextEvent: thuộc tính statusMessage

Baseline Widely available

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

Note: This feature is available in Web Workers.

Thuộc tính chỉ đọc WebGLContextEvent.statusMessage chứa thông tin trạng thái sự kiện bổ sung, hoặc là một chuỗi rỗng nếu không có thông tin bổ sung nào.

Ví dụ

Thuộc tính statusMessage có thể chứa một chuỗi phụ thuộc nền tảng với chi tiết về một sự kiện. Điều này có thể xảy ra, ví dụ, nếu sự kiện webglcontextcreationerror được kích hoạt.

js
const canvas = document.getElementById("canvas");
const gl = canvas.getContext("webgl");

canvas.addEventListener("webglcontextcreationerror", (e) => {
  console.log(
    `WebGL context creation failed: ${e.statusMessage || "Unknown error"}`,
  );
});

Thông số kỹ thuật

Specification
WebGL Specification
# 5.15.1

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

Xem thêm