From http://stackoverflow.com/questions/6041593/javascript-adding-click-event-via-addeventlistener-to-confirm-navigation-from-a