인터넷 익스플로러 이벤트 모델은 다음과 같은 두 가지 메서드로 이벤트를 연결하거나 제거할 수 있다.
첫 번째 매개변수에 이벤트 속성을 쓴다
attachEvent(eventProperty, eventListener);
detachEvent(eventProperty, eventListener);
window.attachEvent('onload',function () {
// load 이벤트 연결
});
인터넷 익스플로러의 이벤트 모델이므로 인터넷 익스플로러에서만 실행됨
window.onload = function () {
var header = document.getElementById('my-header');
// 인터넷 익스플로러의 경우 실행
if (header.attachEvent) {
var handler = function () {
window.event.srcElement.style.color = 'red';
window.event.srcElement.detachEvent('onclick', handler);
};
header.attachEvent('onclick', handler);
}
};
이런게 있구나 정도로 알고있으면 됨!
'Frontend > Java Script' 카테고리의 다른 글
| JS 예외 처리 (part. 01) - 예외 처리 (0) | 2020.07.28 |
|---|---|
| JS event (part. 08) - 표준 이벤트 모델 (0) | 2020.07.28 |
| JS event (part. 06) - 이벤트 전달 (0) | 2020.07.27 |
| JS event (part. 05) - 디폴트 이벤트 제거 (0) | 2020.07.27 |
| JS event (part. 04) - 이벤트 강제 실행 (0) | 2020.07.27 |