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