Event handler for javascript objects.