javascript function hook