Created
April 13, 2019 16:32
-
-
Save meetKowshik/ee95faef217f26dd494cdc29422dfda2 to your computer and use it in GitHub Desktop.
window resize event listener control
This file contains 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
It's better not to overwrite the default window event resize functionality. in order run a function on window resize, this method can be a good way | |
var addEvent = function(object, type, callback) { | |
if (object == null || typeof(object) == 'undefined') return; | |
if (object.addEventListener) { | |
object.addEventListener(type, callback, false); | |
} else if (object.attachEvent) { | |
object.attachEvent("on" + type, callback); | |
} else { | |
object["on"+type] = callback; | |
} | |
}; | |
addEvent(window, "resize", function_reference); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment