Updated Js file to work in firefox

Updated function with event to try and gain Firefox functionality back.