Add 'then' command to call javascript functions.