FontFaceSet: sự kiện loadingerror

Khả dụng hạn chế

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

Note: This feature is available in Web Workers.

Sự kiện loadingerror kích hoạt khi font đã tải xong nhưng một số hoặc tất cả font tải thất bại.

Cú pháp

Dùng tên sự kiện trong các phương thức như addEventListener(), hoặc đặt thuộc tính event handler.

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

onloadingerror = (event) => { }

Ví dụ

Trong ví dụ sau, nếu font Ephesis tải thất bại, "Font loading error" được in ra console.

js
document.fonts.onloadingerror = () => {
  console.log("Font loading error");
};

(async () => {
  await document.fonts.load("16px Ephesis");
})();

Thông số kỹ thuật

Thông số kỹ thuật
CSS Font Loading Module Level 3
# dom-fontfaceset-onloadingerror

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