Implement history api (pushState and popState)