배경 페이지 (background.html)로 관리되는 Chrome 확장 프로그램에 알림 기능이 있습니다 이 페이지는 기본적으로 이전 타이머를 삭제 한 setNotificationDelay() 함수를 호출합니다. setTimeOut크롬 확장의 setTimeOut 범위
function setNotificationDelay() {
clearNotificationTimer();
newDelay = getNotificationDelay()
notificationTimer = setTimeout(showNotification, newDelay);
}
}
은 또한 알림 시간의 구성을 허용하는 options.html 페이지가 있습니다. 구성을 수정할 때 백그라운드 타임 아웃을 수정하고 싶지만 옵션 페이지에서 setNotificationDelay()를 호출하면 작동하지 않으며 타이머의 범위가 상위 페이지에 연결되어 있기 때문에 가정합니다.
옵션 페이지를 열면 시간 초과가 발생하고 닫으면 알림이 표시되지 않습니다.
이 타이머를 백그라운드 페이지에 추가하려면 어떻게해야합니까? 더 좋은 방법이 있나요?
감사합니다.
편집 : chrome.extension는 배경 페이지의 윈도우 객체를 반환 내의 getBackground 페이지 방법이 다음 options.html
페이지가 열려있는 동안
function setNotificationDelay() {
clearNotificationTimer();
newDelay = getNotificationDelay()
notificationTimer = chrome.extension.getBackgroundPage().setTimeout(showNotification, newDelay);
}
}