适用场景:门面模式在DOM脚本编程这种需要对各种不一致的浏览器接口的环境中很常用。

例子:阻止模式事件

 var DED = widow.DED || {};
DED.util = {
stopPropagation:function(e){
if(e.stopPropagation){
e.stopPropagation();
}else{
e.cancelBubble = true; //IE's interface
}
},
preventDefault:function(e){
if(e.preventDefault){
e.preventDefault();
}else{
e.returnValue = false;
}
},
stopEvent:function(e){
DED.util.stopPropagation(e);
DED.util.preventDefault(e);
}
}
05-13 22:22