Notification: lang 屬性
注意:此功能在 Web Workers 中可用。
Notification 介面中只讀的 lang 屬性表示通知中使用的語言,該語言是在 Notification() 建構函式的 lang 選項中指定的。
語言本身使用表示 BCP 47 語言標記 的字串來指定。
值
指定語言標記的字串。
示例
以下程式碼片段會觸發一個通知;建立一個簡單的 options 物件,然後使用 Notification() 建構函式觸發通知。
js
const options = {
body: "Your code submission has received 3 new review comments.",
lang: "en-US",
};
const n = new Notification("New review activity", options);
console.log(n.lang); // "en-US"
規範
| 規範 |
|---|
| Notifications API # dom-notification-lang |
瀏覽器相容性
載入中…