js设计模式-门面模式

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

例子:阻止模式事件

 1 var DED = widow.DED || {};
 2     DED.util = {
 3         stopPropagation:function(e){
 4             if(e.stopPropagation){
 5                 e.stopPropagation();
 6             }else{
 7                 e.cancelBubble = true; //IE's interface
 8             }
 9         },
10         preventDefault:function(e){
11             if(e.preventDefault){
12                 e.preventDefault();
13             }else{
14                 e.returnValue = false;
15             }
16         },
17         stopEvent:function(e){
18             DED.util.stopPropagation(e);
19             DED.util.preventDefault(e);
20         }
21     }
原文地址:https://www.cnblogs.com/tengri/p/5348273.html