Javascript event handler getting called