javascript事件绑定,取消,addEventListener,removeEventListener,attachEvent,detachEvent

javascript事件绑定,取消,addEventListener,removeEventListener,attachEvent,detachEvent

 

function removeScroll() {
            //alert(1);
            if (document.removeEventListener) {
                window.removeEventListener('scroll', fixedFun, false);
            } else {
                window.detachEvent('onscroll', fixedFun);
            }
        }

        document.addEventListener ? window.addEventListener('scroll', fixedFun, false) : window.attachEvent('onscroll', fixedFun);

        document.addEventListener ? document.body.addEventListener('click', removeScroll, false) : document.body.attachEvent('onclick', removeScroll);

 

 

posted on 2012-08-21 17:54  lzf0514  阅读(986)  评论(0编辑  收藏  举报

导航