handle navigation in JS