Prevent the code from running if there is no window.history object