Event Listener function

Better compatibility across browsers and (slightly) less script.