2011-11-14 4 views
0

IE8에서는 Element Interface을 확장 할 수 있으므로 attachEvent/detachEvent와 같이 추상화 할 수 있습니다 ....htc를 통해 IE7에 addEventListener를 추가하십시오.

if (!window.addEventListener) { 
    // Internet Explorer 8 provides access to its 'Element' Interface… 

    window.Element.prototype.addEventListener = function(type, listener, useCapture) { 
     this.attachEvent('on' + type, listener); 
    } 

    window.Element.prototype.removeEventListener = function(type, listener, useCapture) { 
     this.detachEvent('on' + type, listener); 
    } 
} 

...하지만 IE7에서 구현하는 방법은 잘 모르겠습니다. .htc 파일을 통해 가능하다는 소식을 들었습니까?

어떤 방법으로 정확히 표시 할 수 있습니까?

답변

0

Prototype.js, AFAIK는 프로토 타입 대신 작동하지 않는 요소에 ($()을 통해 호출 할 때마다) 해당 메서드를 직접 추가하여이 문제를 해결했습니다.

당신이보고 여기에이 작품을 만들 수있는 해킹에 대한 한을 찾고 있다면 : http://blog.motane.lu/2007/09/20/elementprototype-in-ie/

+0

감사를 링크, 나는 이전 만 가져올 수 없습니다 그것이 작동하는 그것을 시도? – Integralist

+0

이것은 시도 (작동하지 않음)입니다 : https://gist.github.com/1363964 – Integralist