contextualIdentities.onCreated
當建立新的上下文標識時觸發。上下文標識可以由使用 contextualIdentities API 的擴充套件程式建立,也可以由使用者直接透過瀏覽器使用者介面建立。
語法
js
browser.contextualIdentities.onCreated.addListener(listener)
browser.contextualIdentities.onCreated.removeListener(listener)
browser.contextualIdentities.onCreated.hasListener(listener)
事件有三個函式
addListener(listener)-
向此事件新增監聽器。
removeListener(listener)-
停止監聽此事件。
listener引數是要移除的監聽器。 hasListener(listener)-
檢查
listener是否已為此事件註冊。如果正在監聽,則返回true,否則返回false。
addListener 語法
引數
監聽器-
當此事件發生時呼叫的函式。該函式將傳遞此引數
changeInfo-
object。一個包含單個屬性contextualIdentity的物件,該屬性是contextualIdentities.ContextualIdentity物件,代表已建立的標識。
示例
js
function handleCreated(changeInfo) {
console.log(`Created: ${changeInfo.contextualIdentity.name}`);
}
browser.contextualIdentities.onCreated.addListener(handleCreated);
瀏覽器相容性
載入中…