add event processing to JavaScript