Created
April 22, 2015 00:56
-
-
Save RyoSugimoto/f6dcef3765e934497b60 to your computer and use it in GitHub Desktop.
デフォルトイベントとバブリングの抑制(旧IE対応)。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var cancelBubble, | |
cancelEvent; | |
cancelBubble = (function () { | |
var func = function () {}; | |
if (typeof Event !== 'undefined' && typeof Event.prototype.stopPropagation === 'function') { | |
func = function (e) { e.stopPropagation(); }; | |
} else if (window.event) { | |
func = function () { window.event.cancelBubble = true; }; | |
} | |
return func; | |
}()); | |
cancelEvent = (function () { | |
var func = function () {}; | |
if (typeof Event !== 'undefined' && typeof Event.prototype.preventDefault === 'function') { | |
func = function (e) { e.preventDefault(); }; | |
} else if (window.event) { | |
func = function () { window.event.returnValue = false; }; | |
} | |
return func; | |
}()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment