WindowEventHandlers.onstorage
WindowEventHandlers
믹스인의 onstorage
속성은 storage (en-US)
이벤트를 처리하는 EventHandler
(en-US)입니다.
storage
이벤트는 다른 문서에서 저장소를 변경했을 때 발생합니다.
구문
window.onstorage = functionRef;
값
functionRef
는 함수 이름 혹은 함수 표현식으로, 단일 매개변수로써 StorageEvent
를 받습니다.
예제
다음 예제는 다른 문서에서 저장소 키를 바꿀 때마다 메시지를 기록합니다.
window.onstorage = function(e) {
console.log('The ' + e.key +
' key has been changed from ' + e.oldValue +
' to ' + e.newValue + '.');
};
명세
Specification | Status | Comment |
---|---|---|
HTML Living Standard The definition of 'onstorage' in that specification. |
Living Standard |
브라우저 호환성
BCD tables only load in the browser