模式-初始化分支
Posted 佛陀
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了模式-初始化分支相关的知识,希望对你有一定的参考价值。
var MYAPP = {};
MYAPP.event = {
addListener: null,
removeListener: null
};
if (typeof window.addEventListener === ‘function‘) {
MYAPP.event.addListener = function(el, type, fn) {
el.addEventListener(type, fn, false);
};
MYAPP.event.removeListener = function(el, type, fn) {
el.removeListener(type, fn, false);
}
} else if (typeof window.attachEvent === ‘function‘) {
MYAPP.event.addListener = function(el, type, fn) {
el.attachEvent(‘on‘ + type, fn);
};
MYAPP.event.removeListener = function(el, type, fn) {
el.detachEvent(‘on‘ + type, fn);
};
} else {
MYAPP.event.addListener = function(el, type, fn) {
el[‘on‘ + type] = fn;
};
MYAPP.event.removeListener = function(el, type, fn) {
el[‘on‘ + type] = null;
};
};
以上是关于模式-初始化分支的主要内容,如果未能解决你的问题,请参考以下文章