s

해당 브라우저에 지원하는 이벤트 확인

· 2013-02-24 (일) 23:17:13 · 3439 · 1
var isEventSupported = (function(){
    var TAGNAMES = {
      'select':'input','change':'input',
      'submit':'form','reset':'form',
      'error':'img','load':'img','abort':'img'
    }
    function isEventSupported(eventName) {
      var el = document.createElement(TAGNAMES[eventName] || 'div');
      eventName = 'on' + eventName;
      var isSupported = (eventName in el);
      if (!isSupported) {
        el.setAttribute(eventName, 'return;');
        isSupported = typeof el[eventName] == 'function';
      }
      el = null;
      return isSupported;
    }
    return isEventSupported;
  })();

사용법은 isEventSupported(event) 인데 on 빼고 입력하면 됩니다. 여부를 리턴하죠.
링크 #1은 원문이고, 링크 #2는 예제입니다.
요즘 쓸데없는일로 스트레스쌓여서 슬럼프상태입니다. 그렇다보니 이렇게 팁을 퍼오기만 하고.. 쩝.. 일단 충분한 안정이 필요한것같습니다..ㅠㅠ
|

댓글 1개

감사요~
댓글을 작성하시려면 로그인이 필요합니다.

프로그램

8,188건
+
제목 글쓴이 날짜 조회
14-10-13 조회 6,339
14-10-11 조회 6,549
14-10-11 조회 6,456
14-10-11 조회 6,307
14-10-10 조회 6,274
14-10-10 조회 6,038
14-10-08 조회 6,826
14-10-07 조회 6,244
14-10-06 조회 6,616
14-10-06 조회 7,400