javascript for history navigation management