Skip to content

Instantly share code, notes, and snippets.

@meetKowshik
Created April 13, 2019 16:32
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 meetKowshik/ee95faef217f26dd494cdc29422dfda2 to your computer and use it in GitHub Desktop.
Save meetKowshik/ee95faef217f26dd494cdc29422dfda2 to your computer and use it in GitHub Desktop.
window resize event listener control
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