Add applistener to javascript