Skip to content

Instantly share code, notes, and snippets.

@KJlmfe
Created April 26, 2014 02:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KJlmfe/11309881 to your computer and use it in GitHub Desktop.
Save KJlmfe/11309881 to your computer and use it in GitHub Desktop.
JavaScript 设计模式 - Facade(外观模式/门面模式)-封装浏览器差异
var myevent = {
// ...
stop: function (e) {
//其他
if(typeof e.preventDefault === "function") {
e.preventDefault();
}
if(typeof e.stopPropagation === "function") {
e.stopPropagation();
}
//IE
if(typeof e.returnValue === "boolean") {
e.returnValue = false;
}
if(typeof e.cancelBubble === "boolean") {
e.cancelBubble = true;
}
}
// ...
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment