Category
show
전체 (775)
웹표준, 웹접근성™ (5)
웹프로그래밍™ (360)
웹기획™ (0)
웹디자인™ (5)
서버™ (32)
데이터베이스™ (43)
개발자료 (9)
트랜드 (60)
Study English (2)
블루비 (70)
오피스 다이어리 (19)
Textcube (2)
이슈 (20)
컴퓨터 악세사리 (18)
엔터테인먼트 (24)
좋은글 (73)
재테크 (1)
이벤트 (4)

[element].attachEvent("[event]", [function]);
객체의 특정 [event](onmouseover,onmouseout...)가 발생시 정의된[function]을 실행한다.
[element].detachEvent("[event]", [function]);
정의된 [event]의 [function]를 삭제

ex>
document.attachEvent("onmousedown", test);
위처럼 하면 문서에 마우스 다운시 test함수가 실행됩니다.
attachEvent, detachEvent 는 IE 전용이며

모질라 기반 브라우저에서는
[element].addEventListener("mousedown", test, true);
[element].removeEventListener("mousedown", test, true);

[event] 부분이 IE 에선 on을 붙이지만 모질라 기반은 on을 뺀 이벤트만 적용해준다.

크로스 코딩 예제

function addEvent(obj,evt,func)
{
if( /MSIE/.test(navigator.userAgent) ){/* IE */
obj.attachEvent(evt , func);
} else {
evt=evt.replace('on','');
obj.addEventListener(evt , func, false)
}
}

function removeEvent(obj,evt,func){

if( /MSIE/.test(navigator.userAgent) ){/* IE */
obj.detachEvent(evt , func);
}else{
evt=evt.replace('on',');
obj.removeEventListener(evt , func, false)
}
}

2006/09/14 01:35 2006/09/14 01:35

TRACKBACK :: http://blueb.net/blog/trackback/616

Leave a Comment
[로그인][오픈아이디란?]
1  ... 461 462 463 464 465 466 467 468 469  ... 775 

달력

«   2008/11   »
            1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30